add smart usb and cifs searches to game folder paths

This commit is contained in:
Jamie Dickson
2019-12-06 01:01:49 -06:00
committed by sorgelig
parent e04a1d144f
commit 5373f3d978
2 changed files with 42 additions and 1 deletions

View File

@@ -703,13 +703,53 @@ uint32_t getFileType(const char *name)
void prefixGameDir(char *dir, size_t dir_len)
{
// Searches for the core's folder in the following order:
// /media/fat
// /media/usb<0..5>
// /media/usb<0..5>/games
// /media/fat/cifs
// /media/fat/cifs/games
// /media/fat/games/
// if the core folder is not found anywhere,
// it will be created in /media/fat/games/<dir>
if (isPathDirectory(dir)) {
printf("Found existing: %s\n", dir);
return;
}
FileCreatePath((char *) GAMES_DIR);
static char temp_dir[1024];
for (int x = 0; x < 6; x++) {
snprintf(temp_dir, 1024, "%s%d/%s", "../usb", x, dir);
if (isPathDirectory(temp_dir)) {
printf("Found USB dir: %s\n", temp_dir);
strncpy(dir, temp_dir, dir_len);
return;
}
snprintf(temp_dir, 1024, "%s%d/%s/%s", "../usb", x, GAMES_DIR, dir);
if (isPathDirectory(temp_dir)) {
printf("Found USB dir: %s\n", temp_dir);
strncpy(dir, temp_dir, dir_len);
return;
}
}
snprintf(temp_dir, 1024, "%s/%s", CIFS_DIR, dir);
if (isPathDirectory(temp_dir)) {
printf("Found CIFS dir: %s\n", temp_dir);
strncpy(dir, temp_dir, dir_len);
return;
}
snprintf(temp_dir, 1024, "%s/%s/%s", CIFS_DIR, GAMES_DIR, dir);
if (isPathDirectory(temp_dir)) {
printf("Found CIFS dir: %s\n", temp_dir);
strncpy(dir, temp_dir, dir_len);
return;
}
FileCreatePath((char *) GAMES_DIR);
snprintf(temp_dir, 1024, "%s/%s", GAMES_DIR, dir);
strncpy(dir, temp_dir, dir_len);
printf("Prefixed dir to %s\n", temp_dir);

View File

@@ -109,5 +109,6 @@ uint32_t getFileType(const char *name);
#define COEFF_DIR "filters"
#define GAMMA_DIR "gamma"
#define GAMES_DIR "games"
#define CIFS_DIR "cifs"
#endif