58 lines
1.2 KiB
C
58 lines
1.2 KiB
C
// fat12.c
|
|
// Author: Josh Holtrop
|
|
// Created: 01/04/04
|
|
|
|
|
|
byte *fat12_readFile(char *fileName, DiskDevice *dd)
|
|
{
|
|
}
|
|
|
|
Fat12File *fat12_getFileHandle(char *fileName)
|
|
{
|
|
if (strlen(fileName) < 1)
|
|
return 0;
|
|
if (fileName[strlen(fileName)-1] == '/')
|
|
return 0;
|
|
dword numDirectories = 0;
|
|
int a = 0;
|
|
for (;;) //first count how many directories deep we are looking
|
|
{
|
|
if (fileName[a] == '/')
|
|
numDirectories++;
|
|
a++;
|
|
if (!fileName[a])
|
|
break;
|
|
}
|
|
for (a = 0; ;a++) //next split apart the filename string into parts for each directory and file
|
|
{
|
|
if (fileName[a] == 0)
|
|
break;
|
|
if (fileName[a] == '/')
|
|
fileName[a] = 0;
|
|
}
|
|
char **levels = (char**)malloc((numDirectories+1)*sizeof(char *));
|
|
char *dir = fileName;
|
|
for (a = 0; a <= numDirectories; a++)
|
|
{
|
|
levels[a] = dir;
|
|
for (;;)
|
|
{
|
|
dir++;
|
|
if (!(*dir))
|
|
break;
|
|
}
|
|
dir++;
|
|
}
|
|
for (a = 0; a <= numDirectories; a++)
|
|
{
|
|
printf("directory: %s|\n", levels[a]);
|
|
}
|
|
//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);
|
|
}
|
|
|
|
|
|
|