// fat12.c // Author: Josh Holtrop // Created: 01/04/04 byte *fat12_readFile(char *fileName, DiskDevice *dd) { Fat12File *fp = fat12_getFileHandle(fileName, dd); if (!fp) return 0; } Fat12File *fat12_getFileHandle(char *fileName, DiskDevice *dd) { if (strlen(fileName) < 1) return 0; if (fileName[strlen(fileName)-1] == '/') return 0; } //The trailing slash ('/') character should not be included in the directory string Fat12Directory *fat12_getDirectoryHandle(char *directory, DiskDevice *dd) { dword numDirectories = 0; int a = 0; for (;;) //first count how many directories deep we are looking { if (directory[a] == '/') numDirectories++; a++; if (!directory[a]) break; } for (a = 0; ;a++) //next split apart the filename string into parts for each directory and file { if (directory[a] == 0) break; if (directory[a] == '/') directory[a] = 0; } char **levels = (char**)malloc((numDirectories+1)*sizeof(char *)); char *dir = directory; for (a = 0; a <= numDirectories; a++) { levels[a] = dir; for (;;) { dir++; if (!(*dir)) break; } dir++; } //at this point we have an array of "strings" (character pointers) called levels // its length is numDirectories+1, levels[numDirectores] points to the actual file name free(levels); }