[ORBIS] Add retro_dirent support

This commit is contained in:
psxdev 2019-01-03 14:40:10 +01:00 committed by Francisco José García García
parent d52de24e79
commit 1fd88b865e

View File

@ -50,6 +50,11 @@
# include <psp2/io/fcntl.h> # include <psp2/io/fcntl.h>
# include <psp2/io/dirent.h> # include <psp2/io/dirent.h>
# include <psp2/io/stat.h> # include <psp2/io/stat.h>
#elif defined(ORBIS)
# include <orbisFile.h>
# include <ps4link.h>
# include <sys/dirent.h>
# include <sys/fcntl.h>
#else #else
# if defined(PSP) # if defined(PSP)
# include <pspiofilemgr.h> # include <pspiofilemgr.h>
@ -98,6 +103,9 @@ struct RDIR
CellFsErrno error; CellFsErrno error;
int directory; int directory;
CellFsDirent entry; CellFsDirent entry;
#elif defined(ORBIS)
int directory;
struct dirent entry;
#else #else
DIR *directory; DIR *directory;
const struct dirent *entry; const struct dirent *entry;
@ -159,6 +167,8 @@ struct RDIR *retro_opendir(const char *name)
rdir->entry = NULL; rdir->entry = NULL;
#elif defined(__CELLOS_LV2__) #elif defined(__CELLOS_LV2__)
rdir->error = cellFsOpendir(name, &rdir->directory); rdir->error = cellFsOpendir(name, &rdir->directory);
#elif defined(ORBIS)
rdir->directory = orbisDopen(name);
#else #else
rdir->directory = opendir(name); rdir->directory = opendir(name);
rdir->entry = NULL; rdir->entry = NULL;
@ -175,7 +185,7 @@ bool retro_dirent_error(struct RDIR *rdir)
{ {
#if defined(_WIN32) #if defined(_WIN32)
return (rdir->directory == INVALID_HANDLE_VALUE); return (rdir->directory == INVALID_HANDLE_VALUE);
#elif defined(VITA) || defined(PSP) || defined(PS2) #elif defined(VITA) || defined(PSP) || defined(PS2) || defined(ORBIS)
return (rdir->directory < 0); return (rdir->directory < 0);
#elif defined(__CELLOS_LV2__) #elif defined(__CELLOS_LV2__)
return (rdir->error != CELL_FS_SUCCEEDED); return (rdir->error != CELL_FS_SUCCEEDED);
@ -207,6 +217,8 @@ int retro_readdir(struct RDIR *rdir)
uint64_t nread; uint64_t nread;
rdir->error = cellFsReaddir(rdir->directory, &rdir->entry, &nread); rdir->error = cellFsReaddir(rdir->directory, &rdir->entry, &nread);
return (nread != 0); return (nread != 0);
#elif defined(ORBIS)
return (orbisDread(rdir->directory, &rdir->entry) > 0);
#else #else
return ((rdir->entry = readdir(rdir->directory)) != NULL); return ((rdir->entry = readdir(rdir->directory)) != NULL);
#endif #endif
@ -231,7 +243,7 @@ const char *retro_dirent_get_name(struct RDIR *rdir)
free(name); free(name);
#endif #endif
return (char*)rdir->entry.cFileName; return (char*)rdir->entry.cFileName;
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) #elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) || defined(ORBIS)
return rdir->entry.d_name; return rdir->entry.d_name;
#elif defined(PS2) #elif defined(PS2)
return rdir->entry.name; return rdir->entry.name;
@ -270,6 +282,14 @@ bool retro_dirent_is_dir(struct RDIR *rdir, const char *path)
#elif defined(__CELLOS_LV2__) #elif defined(__CELLOS_LV2__)
CellFsDirent *entry = (CellFsDirent*)&rdir->entry; CellFsDirent *entry = (CellFsDirent*)&rdir->entry;
return (entry->d_type == CELL_FS_TYPE_DIRECTORY); return (entry->d_type == CELL_FS_TYPE_DIRECTORY);
#elif defined(ORBIS)
const struct dirent *entry = &rdir->entry;
if (entry->d_type==DT_DIR)
{
return true;
}
if (!(entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK))
return false;
#else #else
struct stat buf; struct stat buf;
#if defined(DT_DIR) #if defined(DT_DIR)
@ -311,6 +331,8 @@ void retro_closedir(struct RDIR *rdir)
fileXioDclose(rdir->directory); fileXioDclose(rdir->directory);
#elif defined(__CELLOS_LV2__) #elif defined(__CELLOS_LV2__)
rdir->error = cellFsClosedir(rdir->directory); rdir->error = cellFsClosedir(rdir->directory);
#elif defined(ORBIS)
orbisDclose(rdir->directory);
#else #else
if (rdir->directory) if (rdir->directory)
closedir(rdir->directory); closedir(rdir->directory);