From f7631c41cde5ae6508916e8d06e29dec90ebe223 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 30 Aug 2015 17:23:01 +0200 Subject: [PATCH] Backport xerpi's patch --- Makefile.griffin | 5 ++-- file_ops.c | 3 ++ file_path_special.c | 3 ++ libretro-common/file/dir_list.c | 48 ++++++++++++++++++++++++++++++-- libretro-common/file/file_path.c | 3 ++ 5 files changed, 57 insertions(+), 5 deletions(-) diff --git a/Makefile.griffin b/Makefile.griffin index f904b0f0e2..f3a3756198 100644 --- a/Makefile.griffin +++ b/Makefile.griffin @@ -147,11 +147,12 @@ else ifeq ($(platform), vita) MACHDEP := -DVITA PLATCFLAGS := -Wl,-q -Wall -O3 LIBS += -lSceKernel_stub -lSceDisplay_stub -lSceGxm_stub \ - -lSceSysmodule_stub -lSceCtrl_stub -lScePgf_stub \ - -lpng -ljpeg -lfreetype -lz -lm -lc + -lSceSysmodule_stub -lSceCtrl_stub -lSceAudio_stub \ + -lSceRtc_stub -lz -lm -lc HAVE_LIBRETRO_MANAGEMENT := 1 HAVE_RPNG := 1 + HAVE_ZLIB := 1 HAVE_VITA2D := 1 endif diff --git a/file_ops.c b/file_ops.c index 090003c6e2..148f3c6fc0 100644 --- a/file_ops.c +++ b/file_ops.c @@ -54,6 +54,9 @@ #include #include #endif +#elif defined(VITA) +#include +#include #else #include #include diff --git a/file_path_special.c b/file_path_special.c index bf7e732cc4..b87474ca39 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -59,6 +59,9 @@ #include #include #endif +#elif defined(VITA) +#include +#include #else #include #include diff --git a/libretro-common/file/dir_list.c b/libretro-common/file/dir_list.c index 0071a7078d..1d290cde3f 100644 --- a/libretro-common/file/dir_list.c +++ b/libretro-common/file/dir_list.c @@ -38,6 +38,9 @@ #include #include #endif +#elif defined(VITA) +#include +#include #else #include #include @@ -96,7 +99,7 @@ void dir_list_free(struct string_list *list) string_list_free(list); } -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(VITA) /** * * dirent_is_directory: @@ -209,9 +212,12 @@ static int parse_dir_entry(const char *name, char *file_path, struct string_list *dir_list_new(const char *dir, const char *ext, bool include_dirs, bool include_compressed) { -#ifdef _WIN32 +#if defined(_WIN32) WIN32_FIND_DATA ffd; HANDLE hFind = INVALID_HANDLE_VALUE; +#elif defined(VITA) + SceUID directory; + SceIoDirent entry; #else DIR *directory = NULL; const struct dirent *entry = NULL; @@ -262,6 +268,43 @@ struct string_list *dir_list_new(const char *dir, error: if (hFind != INVALID_HANDLE_VALUE) FindClose(hFind); +#elif defined(VITA) + directory = sceIoDopen(dir); + if (directory < 0) + goto error; + + while (sceIoDread(directory, &entry) > 0) + { + char file_path[PATH_MAX_LENGTH]; + int ret = 0; + const char *name = entry.d_name; + const char *file_ext = path_get_extension(name); + bool is_dir = false; + + fill_pathname_join(file_path, dir, name, sizeof(file_path)); + + is_dir = PSP2_S_ISDIR(entry.d_stat.st_mode); + + ret = parse_dir_entry(name, file_path, is_dir, + include_dirs, include_compressed, list, ext_list, file_ext); + + if (ret == -1) + { + sceIoDclose(directory); + goto error; + } + + if (ret == 1) + continue; + } + + sceIoDclose(directory); + + string_list_free(ext_list); + return list; + +error: + #else directory = opendir(dir); if (!directory) @@ -297,7 +340,6 @@ error: error: if (directory) closedir(directory); - #endif string_list_free(list); string_list_free(ext_list); diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 9e7ca8e732..7fd3760f7c 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -63,6 +63,9 @@ #include #include #endif +#elif defined(VITA) +#include +#include #else #include #include