mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-24 03:29:22 +01:00
replace file calls with standard ones
This commit is contained in:
parent
5d7331ead0
commit
d968149ac5
@ -16,7 +16,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ogcsys.h>
|
||||
#include <sys/dir.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <zlib.h>
|
||||
#include <malloc.h>
|
||||
@ -55,7 +55,7 @@ bool isMounted[7] = { false, false, false, false, false, false, false };
|
||||
|
||||
// folder parsing thread
|
||||
static lwp_t parsethread = LWP_THREAD_NULL;
|
||||
static DIR_ITER * dirIter = NULL;
|
||||
static DIR *dir = NULL;
|
||||
static bool parseHalt = true;
|
||||
static bool parseFilter = true;
|
||||
bool ParseDirEntries();
|
||||
@ -480,27 +480,27 @@ static char *GetExt(char *file)
|
||||
|
||||
bool ParseDirEntries()
|
||||
{
|
||||
if(!dirIter)
|
||||
if(!dir)
|
||||
return false;
|
||||
|
||||
char filename[MAXPATHLEN];
|
||||
char *ext;
|
||||
struct dirent *entry;
|
||||
struct stat filestat;
|
||||
|
||||
int i = 0;
|
||||
int res;
|
||||
|
||||
while(i < 20)
|
||||
{
|
||||
res = dirnext(dirIter,filename,&filestat);
|
||||
entry = readdir(dir);
|
||||
|
||||
if(res != 0)
|
||||
if(entry == NULL)
|
||||
break;
|
||||
|
||||
if(filename[0] == '.' && filename[1] != '.')
|
||||
if(entry->d_name[0] == '.' && entry->d_name[1] != '.')
|
||||
continue;
|
||||
|
||||
ext = GetExt(filename);
|
||||
ext = GetExt(entry->d_name);
|
||||
stat(entry->d_name,&filestat);
|
||||
|
||||
// don't show the file if it's not a valid ROM
|
||||
if(parseFilter && (filestat.st_mode & _IFDIR) == 0)
|
||||
@ -520,14 +520,14 @@ bool ParseDirEntries()
|
||||
break;
|
||||
}
|
||||
|
||||
strncpy(browserList[browser.numEntries+i].filename, filename, MAXJOLIET);
|
||||
strncpy(browserList[browser.numEntries+i].filename, entry->d_name, MAXJOLIET);
|
||||
browserList[browser.numEntries+i].length = filestat.st_size;
|
||||
browserList[browser.numEntries+i].mtime = filestat.st_mtime;
|
||||
browserList[browser.numEntries+i].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
||||
|
||||
if(browserList[browser.numEntries+i].isdir)
|
||||
{
|
||||
if(strcmp(filename, "..") == 0)
|
||||
if(strcmp(entry->d_name, "..") == 0)
|
||||
sprintf(browserList[browser.numEntries+i].displayname, "Up One Level");
|
||||
else
|
||||
strncpy(browserList[browser.numEntries+i].displayname, browserList[browser.numEntries+i].filename, MAXJOLIET);
|
||||
@ -546,10 +546,10 @@ bool ParseDirEntries()
|
||||
|
||||
browser.numEntries += i;
|
||||
|
||||
if(res != 0 || parseHalt)
|
||||
if(entry == NULL || parseHalt)
|
||||
{
|
||||
dirclose(dirIter); // close directory
|
||||
dirIter = NULL;
|
||||
closedir(dir); // close directory
|
||||
dir = NULL;
|
||||
|
||||
// try to find and select the last loaded file
|
||||
if(selectLoadedFile == 1 && parseHalt == 0 && loadedFile[0] != 0 && browser.dir[0] != 0)
|
||||
@ -603,23 +603,23 @@ ParseDirectory(bool waitParse, bool filter)
|
||||
ResetBrowser(); // reset browser
|
||||
|
||||
// open the directory
|
||||
while(dirIter == NULL && retry == 1)
|
||||
while(dir == NULL && retry == 1)
|
||||
{
|
||||
mounted = ChangeInterface(browser.dir, NOTSILENT);
|
||||
|
||||
if(mounted)
|
||||
dirIter = diropen(browser.dir);
|
||||
dir = opendir(browser.dir);
|
||||
else
|
||||
return -1;
|
||||
|
||||
if(dirIter == NULL)
|
||||
if(dir == NULL)
|
||||
{
|
||||
retry = ErrorPromptRetry("Error opening directory!");
|
||||
}
|
||||
}
|
||||
|
||||
// if we can't open the dir, try higher levels
|
||||
if (dirIter == NULL)
|
||||
if (dir == NULL)
|
||||
{
|
||||
char * devEnd = strrchr(browser.dir, '/');
|
||||
|
||||
@ -632,13 +632,13 @@ ParseDirectory(bool waitParse, bool filter)
|
||||
break;
|
||||
|
||||
devEnd[1] = 0; // strip remaining file listing
|
||||
dirIter = diropen(browser.dir);
|
||||
if (dirIter)
|
||||
dir = opendir(browser.dir);
|
||||
if (dir)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dirIter == NULL)
|
||||
if(dir == NULL)
|
||||
return -1;
|
||||
|
||||
if(IsDeviceRoot(browser.dir))
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/dir.h>
|
||||
#include <dirent.h>
|
||||
#include <ogcsys.h>
|
||||
#include <mxml.h>
|
||||
|
||||
@ -502,7 +502,7 @@ SavePrefs (bool silent)
|
||||
return false;
|
||||
|
||||
sprintf(filepath, "%s%s", pathPrefix[device], APPFOLDER);
|
||||
DIR_ITER *dir = diropen(filepath);
|
||||
DIR *dir = opendir(filepath);
|
||||
if (!dir)
|
||||
{
|
||||
if(mkdir(filepath, 0777) != 0)
|
||||
@ -516,7 +516,7 @@ SavePrefs (bool silent)
|
||||
}
|
||||
else
|
||||
{
|
||||
dirclose(dir);
|
||||
closedir(dir);
|
||||
}
|
||||
sprintf(filepath, "%s%s/%s", pathPrefix[device], APPFOLDER, PREF_FILE_NAME);
|
||||
sprintf(prefpath, "%s%s", pathPrefix[device], APPFOLDER);
|
||||
@ -623,17 +623,17 @@ bool LoadPrefs()
|
||||
// rename snes9x to snes9xgx
|
||||
if(GCSettings.LoadMethod == DEVICE_SD)
|
||||
{
|
||||
if(ChangeInterface(DEVICE_SD, NOTSILENT) && diropen("sd:/snes9x"))
|
||||
if(ChangeInterface(DEVICE_SD, NOTSILENT) && opendir("sd:/snes9x"))
|
||||
rename("sd:/snes9x", "sd:/snes9xgx");
|
||||
}
|
||||
else if(GCSettings.LoadMethod == DEVICE_USB)
|
||||
{
|
||||
if(ChangeInterface(DEVICE_USB, NOTSILENT) && diropen("usb:/snes9x"))
|
||||
if(ChangeInterface(DEVICE_USB, NOTSILENT) && opendir("usb:/snes9x"))
|
||||
rename("usb:/snes9x", "usb:/snes9xgx");
|
||||
}
|
||||
else if(GCSettings.LoadMethod == DEVICE_SMB)
|
||||
{
|
||||
if(ChangeInterface(DEVICE_SMB, NOTSILENT) && diropen("smb:/snes9x"))
|
||||
if(ChangeInterface(DEVICE_SMB, NOTSILENT) && opendir("smb:/snes9x"))
|
||||
rename("smb:/snes9x", "smb:/snes9xgx");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user