mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-05 02:55:07 +01:00
32144f46f9
*Lots of small fixes *Added Error002fix selection in GameSettings **NOTE 1: You might want to delete your Configfiles before using this new Rev. **NOTE 2: Known issue with Settings is that WiiMotePointer is sometimes being displaced. I am searching for the reason right now.
79 lines
1.3 KiB
C
79 lines
1.3 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <gccore.h>
|
|
#include <fat.h>
|
|
#include <sys/dir.h>
|
|
#include <dirent.h>
|
|
#include <unistd.h>
|
|
|
|
#include "listfiles.h"
|
|
|
|
|
|
static char alldirfiles[300][70];
|
|
char filenames[80];
|
|
|
|
bool findfile(const char * filename, const char * path)
|
|
{
|
|
DIR *dir;
|
|
struct dirent *file;
|
|
|
|
dir = opendir(path);
|
|
|
|
char temp[11];
|
|
while ((file = readdir(dir)))
|
|
{
|
|
snprintf(temp,sizeof(temp),"%s",file->d_name);
|
|
if (!strncmpi(temp,filename,11))
|
|
{
|
|
//WindowPrompt(path, filename,"go" ,0);
|
|
closedir(dir);
|
|
return true;
|
|
}
|
|
}
|
|
closedir(dir);
|
|
return false;
|
|
}
|
|
|
|
char * GetFileName(int i)
|
|
{
|
|
return alldirfiles[i];
|
|
}
|
|
|
|
s32 filenamescmp(const void *a, const void *b)
|
|
{
|
|
/* Compare strings */
|
|
return stricmp((char *)a, (char *)b);
|
|
}
|
|
|
|
int GetAllDirFiles(char * filespath)
|
|
{
|
|
|
|
int countfiles = 0;
|
|
|
|
struct stat st;
|
|
DIR_ITER* dir;
|
|
dir = diropen (filespath);
|
|
|
|
if (dir == NULL) //If empty
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
while (dirnext(dir,filenames,&st) == 0)
|
|
{
|
|
if ((st.st_mode & S_IFDIR) == 0)
|
|
{
|
|
// st.st_mode & S_IFDIR indicates a directory
|
|
snprintf(alldirfiles[countfiles], 70, "%s", filenames);
|
|
countfiles++;
|
|
}
|
|
}
|
|
}
|
|
|
|
qsort(alldirfiles, countfiles, sizeof(char[70]), filenamescmp);
|
|
|
|
return countfiles;
|
|
}
|