isle-portable/ISLE/switch/filesys.cpp
SnepOMatic (Rhew) 2897078032 Switch Port
Todo: Fix: Misc crashes when interacting on island.
Todo: Fix: Joystick pointer is slow to move.
Todo: Fix: Touch doesn't behave.
2025-11-10 23:59:37 +00:00

30 lines
600 B
C++

#include <cstdio>
#include <sys/stat.h>
#include "filesys.h"
bool NX_GetPathInfo(const char *path, SDL_PathInfo *info)
{
struct stat st_info;
if (stat(path, &st_info) != 0)
{
if (info) info->type = SDL_PATHTYPE_NONE;
return false;
}
if (st_info.st_mode & S_IFDIR)
{
if (info)info->type = SDL_PATHTYPE_DIRECTORY;
return true;
}
if (info) info->type = SDL_PATHTYPE_FILE;
if (!info) return true;
auto *fp = fopen(path, "r");
fseek(fp, 0, SEEK_END);
if (info) info->size = ftell(fp);
fclose(fp);
return true;
}