6static char dirstack[
MAX_DIRDEPTH][MAX_FILE_NAME_SIZE + 1];
7static int dirdepth = -1;
9static bool push_dir (
const char *dir)
11 if (dirdepth + 1 <
MAX_DIRDEPTH && strlen(dir) <= MAX_FILE_NAME_SIZE)
13 strcpy(dirstack[++dirdepth], dir);
19static bool pop_dir (
char *dir)
23 strcpy(dir, dirstack[dirdepth--]);
29static bool GetFileDir (
const char *FileName,
const char *Dir,
const char *ext)
32 TYPE_FolderEntry entry;
34 TAP_Hdd_ChangeDir(Dir);
36 files = TAP_Hdd_FindFirst(&entry, ext);
40 if (entry.attr == ATTR_FOLDER) push_dir(entry.name);
41 else if (strcmp(entry.name, FileName) == 0)
return TRUE;
43 TAP_Hdd_FindNext(&entry);
51 const char *ext = NULL;
52 char dirname[MAX_FILE_NAME_SIZE + 1];
57 if (!FileName || !Dir || ((
int) Root < DIR_ROOT || Root >
DIR_TMP))
63 if (strlen(FileName) > 4) ext = strrchr(FileName,
'.');
72 strcpy(Dir,
"/DataFiles");
76 strcpy(Dir,
"/ProgramFiles");
80 strcpy(Dir,
"/MP3Files");
84 strcpy(Dir,
"/Incoming");
88 strcpy(Dir,
"/MediaFiles");
92 strcpy(Dir,
"/PhotoFiles");
96 strcpy(Dir,
"/SystemFiles");
106 result = GetFileDir(FileName, Dir, ext);
108 while (!result && pop_dir(dirname))
112 strcpy(Dir, dirname);
118 if (!push_dir(Dir))
break;
120 if (strcmp(Dir,
"/") != 0) strcat(Dir,
"/");
122 strcat(Dir, dirname);
124 result = GetFileDir(FileName, Dir, ext);
128 if (!result) *Dir = 0;
bool HDD_GetFileDir(const char *FileName, eRootDirs Root, char *Dir)
bool HDD_TAP_PushDir(void)
bool HDD_TAP_PopDir(void)