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