mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 10:31:16 +00:00
Fix: base GetPathInfo fixup in the SDL implementation, with check for null SDL_PathInfo.
Fix: Disable imgui shell functions. Todo: Display imgui debug if enabled.
This commit is contained in:
parent
63e24a6d38
commit
4a000cc322
@ -22,6 +22,7 @@ if (NINTENDO_SWITCH)
|
|||||||
set(CMAKE_TOOLCHAIN_FILE "${DEVKITPRO}/cmake/Switch.cmake" CACHE PATH "toolchain file")
|
set(CMAKE_TOOLCHAIN_FILE "${DEVKITPRO}/cmake/Switch.cmake" CACHE PATH "toolchain file")
|
||||||
add_compile_definitions(__SWITCH__)
|
add_compile_definitions(__SWITCH__)
|
||||||
add_compile_definitions(SDL_VIDEO_DRIVER_SWITCH)
|
add_compile_definitions(SDL_VIDEO_DRIVER_SWITCH)
|
||||||
|
add_compile_definitions(IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||||
|
|||||||
@ -1,30 +1,41 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <cerrno>
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
#include "filesys.h"
|
#include "filesys.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Missing from Switch SDL3 implementation
|
||||||
|
#ifndef S_ISREG
|
||||||
|
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Uses core of SDL's SDL_GetPathInfo but handles null 'info'.
|
||||||
bool NX_GetPathInfo(const char *path, SDL_PathInfo *info)
|
bool NX_GetPathInfo(const char *path, SDL_PathInfo *info)
|
||||||
{
|
{
|
||||||
struct stat st_info;
|
SDL_PathInfo tmp_info;
|
||||||
if (stat(path, &st_info) != 0)
|
struct stat statbuf;
|
||||||
{
|
const int rc = stat(path, &statbuf);
|
||||||
if (info) info->type = SDL_PATHTYPE_NONE;
|
|
||||||
return false;
|
if (rc < 0) {
|
||||||
|
return SDL_SetError("Can't stat: %s", strerror(errno));
|
||||||
|
} else if (S_ISREG(statbuf.st_mode)) {
|
||||||
|
tmp_info.type = SDL_PATHTYPE_FILE;
|
||||||
|
tmp_info.size = (Uint64) statbuf.st_size;
|
||||||
|
} else if (S_ISDIR(statbuf.st_mode)) {
|
||||||
|
tmp_info.type = SDL_PATHTYPE_DIRECTORY;
|
||||||
|
tmp_info.size = 0;
|
||||||
|
} else {
|
||||||
|
tmp_info.type = SDL_PATHTYPE_OTHER;
|
||||||
|
tmp_info.size = (Uint64) statbuf.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st_info.st_mode & S_IFDIR)
|
tmp_info.create_time = (SDL_Time)SDL_SECONDS_TO_NS(statbuf.st_ctime);
|
||||||
{
|
tmp_info.modify_time = (SDL_Time)SDL_SECONDS_TO_NS(statbuf.st_mtime);
|
||||||
if (info)info->type = SDL_PATHTYPE_DIRECTORY;
|
tmp_info.access_time = (SDL_Time)SDL_SECONDS_TO_NS(statbuf.st_atime);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info) info->type = SDL_PATHTYPE_FILE;
|
if (info) *info = tmp_info;
|
||||||
if (!info) return true;
|
|
||||||
|
|
||||||
auto *fp = fopen(path, "r");
|
|
||||||
fseek(fp, 0, SEEK_END);
|
|
||||||
if (info) info->size = ftell(fp);
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -4,7 +4,6 @@
|
|||||||
#include <SDL3/SDL_filesystem.h>
|
#include <SDL3/SDL_filesystem.h>
|
||||||
|
|
||||||
#define SDL_GetPathInfo NX_GetPathInfo // Override broken SDL_GetPathInfo
|
#define SDL_GetPathInfo NX_GetPathInfo // Override broken SDL_GetPathInfo
|
||||||
|
|
||||||
bool NX_GetPathInfo(const char *path, SDL_PathInfo *info);
|
bool NX_GetPathInfo(const char *path, SDL_PathInfo *info);
|
||||||
|
|
||||||
#endif // NX_FILESYS_H
|
#endif // NX_FILESYS_H
|
||||||
Loading…
Reference in New Issue
Block a user