mirror of
https://github.com/reactos/reactos.git
synced 2024-07-06 12:45:16 +00:00
[FATTEN]
Change tabs to spaces, but only for the files I write. The rest come directly from the fatfs package and are best left untouched. svn path=/trunk/; revision=69065
This commit is contained in:
parent
163427942d
commit
1a2ad3befe
|
@ -14,25 +14,25 @@ extern char* imageFileName;
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Correspondence between physical drive number and image file handles. */
|
/* Correspondence between physical drive number and image file handles. */
|
||||||
|
|
||||||
FILE* driveHandle[1] = {NULL};
|
FILE* driveHandle[1] = { NULL };
|
||||||
const int driveHandleCount = sizeof(driveHandle) / sizeof(FILE*);
|
const int driveHandleCount = sizeof(driveHandle) / sizeof(FILE*);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Inidialize a Drive */
|
/* Inidialize a Drive */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
DSTATUS disk_initialize (
|
DSTATUS disk_initialize(
|
||||||
BYTE pdrv /* Physical drive nmuber (0..) */
|
BYTE pdrv /* Physical drive nmuber (0..) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(pdrv == 0) // only one drive (image file) supported atm.
|
if (pdrv == 0) /* only one drive (image file) supported atm. */
|
||||||
{
|
{
|
||||||
if(driveHandle[0]!=NULL)
|
if (driveHandle[0] != NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
driveHandle[0]=fopen(imageFileName, "r+b");
|
driveHandle[0] = fopen(imageFileName, "r+b");
|
||||||
|
|
||||||
if(driveHandle[0]!=NULL)
|
if (driveHandle[0] != NULL)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return STA_NOINIT;
|
return STA_NOINIT;
|
||||||
|
@ -44,13 +44,13 @@ DSTATUS disk_initialize (
|
||||||
/* Get Disk Status */
|
/* Get Disk Status */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
DSTATUS disk_status (
|
DSTATUS disk_status(
|
||||||
BYTE pdrv /* Physical drive nmuber (0..) */
|
BYTE pdrv /* Physical drive nmuber (0..) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(pdrv < driveHandleCount)
|
if (pdrv < driveHandleCount)
|
||||||
{
|
{
|
||||||
if(driveHandle[pdrv] != NULL)
|
if (driveHandle[pdrv] != NULL)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return STA_NOINIT;
|
return STA_NOINIT;
|
||||||
|
@ -62,25 +62,25 @@ DSTATUS disk_status (
|
||||||
/* Read Sector(s) */
|
/* Read Sector(s) */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRESULT disk_read (
|
DRESULT disk_read(
|
||||||
BYTE pdrv, /* Physical drive nmuber (0..) */
|
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||||
BYTE *buff, /* Data buffer to store read data */
|
BYTE *buff, /* Data buffer to store read data */
|
||||||
DWORD sector, /* Sector address (LBA) */
|
DWORD sector, /* Sector address (LBA) */
|
||||||
UINT count /* Number of sectors to read (1..128) */
|
UINT count /* Number of sectors to read (1..128) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD result;
|
DWORD result;
|
||||||
|
|
||||||
if(pdrv < driveHandleCount)
|
if (pdrv < driveHandleCount)
|
||||||
{
|
{
|
||||||
if(driveHandle[pdrv] != NULL)
|
if (driveHandle[pdrv] != NULL)
|
||||||
{
|
{
|
||||||
if(fseek(driveHandle[pdrv], sector * 512, SEEK_SET))
|
if (fseek(driveHandle[pdrv], sector * 512, SEEK_SET))
|
||||||
return RES_ERROR;
|
return RES_ERROR;
|
||||||
|
|
||||||
result = fread(buff, 512, count, driveHandle[pdrv]);
|
result = fread(buff, 512, count, driveHandle[pdrv]);
|
||||||
|
|
||||||
if(result == count)
|
if (result == count)
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
|
|
||||||
return RES_ERROR;
|
return RES_ERROR;
|
||||||
|
@ -97,26 +97,26 @@ DRESULT disk_read (
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if _USE_WRITE
|
#if _USE_WRITE
|
||||||
DRESULT disk_write (
|
DRESULT disk_write(
|
||||||
BYTE pdrv, /* Physical drive nmuber (0..) */
|
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||||
const BYTE *buff, /* Data to be written */
|
const BYTE *buff, /* Data to be written */
|
||||||
DWORD sector, /* Sector address (LBA) */
|
DWORD sector, /* Sector address (LBA) */
|
||||||
UINT count /* Number of sectors to write (1..128) */
|
UINT count /* Number of sectors to write (1..128) */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD result;
|
DWORD result;
|
||||||
|
|
||||||
if(pdrv < driveHandleCount)
|
if (pdrv < driveHandleCount)
|
||||||
{
|
{
|
||||||
if(driveHandle[pdrv] != NULL)
|
if (driveHandle[pdrv] != NULL)
|
||||||
{
|
{
|
||||||
if(fseek(driveHandle[pdrv], sector * 512, SEEK_SET))
|
if (fseek(driveHandle[pdrv], sector * 512, SEEK_SET))
|
||||||
return RES_ERROR;
|
return RES_ERROR;
|
||||||
|
|
||||||
result = fwrite(buff, 512, count, driveHandle[pdrv]);
|
result = fwrite(buff, 512, count, driveHandle[pdrv]);
|
||||||
return RES_ERROR;
|
return RES_ERROR;
|
||||||
|
|
||||||
if(result != (512 * count))
|
if (result != (512 * count))
|
||||||
return RES_ERROR;
|
return RES_ERROR;
|
||||||
|
|
||||||
return RES_OK;
|
return RES_OK;
|
||||||
|
@ -133,17 +133,17 @@ DRESULT disk_write (
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if _USE_IOCTL
|
#if _USE_IOCTL
|
||||||
DRESULT disk_ioctl (
|
DRESULT disk_ioctl(
|
||||||
BYTE pdrv, /* Physical drive nmuber (0..) */
|
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||||
BYTE cmd, /* Control code */
|
BYTE cmd, /* Control code */
|
||||||
void *buff /* Buffer to send/receive control data */
|
void *buff /* Buffer to send/receive control data */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(pdrv < driveHandleCount)
|
if (pdrv < driveHandleCount)
|
||||||
{
|
{
|
||||||
if(driveHandle[pdrv] != NULL)
|
if (driveHandle[pdrv] != NULL)
|
||||||
{
|
{
|
||||||
switch(cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case CTRL_SYNC:
|
case CTRL_SYNC:
|
||||||
fflush(driveHandle[pdrv]);
|
fflush(driveHandle[pdrv]);
|
||||||
|
@ -166,9 +166,9 @@ DRESULT disk_ioctl (
|
||||||
fseek(driveHandle[pdrv], 0, SEEK_END);
|
fseek(driveHandle[pdrv], 0, SEEK_END);
|
||||||
size = ftell(driveHandle[pdrv]) / 512;
|
size = ftell(driveHandle[pdrv]) / 512;
|
||||||
|
|
||||||
if(size < count)
|
if (size < count)
|
||||||
{
|
{
|
||||||
if(fseek(driveHandle[pdrv], count * 512 - 1, SEEK_SET))
|
if (fseek(driveHandle[pdrv], count * 512 - 1, SEEK_SET))
|
||||||
return RES_ERROR;
|
return RES_ERROR;
|
||||||
|
|
||||||
fwrite(buff, 1, 1, driveHandle[pdrv]);
|
fwrite(buff, 1, 1, driveHandle[pdrv]);
|
||||||
|
|
|
@ -26,8 +26,8 @@ DWORD get_fattime()
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm * timeinfo;
|
struct tm * timeinfo;
|
||||||
|
|
||||||
time (&rawtime);
|
time(&rawtime);
|
||||||
timeinfo = localtime (&rawtime);
|
timeinfo = localtime(&rawtime);
|
||||||
|
|
||||||
union FatTime {
|
union FatTime {
|
||||||
struct {
|
struct {
|
||||||
|
@ -55,7 +55,7 @@ DWORD get_fattime()
|
||||||
|
|
||||||
BOOL is_command(const char* parg)
|
BOOL is_command(const char* parg)
|
||||||
{
|
{
|
||||||
return (parg[0]=='/') || (parg[0] == '-');
|
return (parg[0] == '/') || (parg[0] == '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NEED_PARAMS(_min_,_max_) \
|
#define NEED_PARAMS(_min_,_max_) \
|
||||||
|
@ -66,11 +66,11 @@ BOOL is_command(const char* parg)
|
||||||
|
|
||||||
BOOL need_mount()
|
BOOL need_mount()
|
||||||
{
|
{
|
||||||
if(isMounted)
|
if (isMounted)
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
|
|
||||||
int r = f_mount(&g_Filesystem, "0:", 0);
|
int r = f_mount(&g_Filesystem, "0:", 0);
|
||||||
if(r)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
isMounted = 1;
|
isMounted = 1;
|
||||||
|
@ -87,16 +87,16 @@ BOOL need_mount()
|
||||||
int main(int oargc, char* oargv[])
|
int main(int oargc, char* oargv[])
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int argc = oargc-1;
|
int argc = oargc - 1;
|
||||||
char** argv = oargv+1;
|
char** argv = oargv + 1;
|
||||||
|
|
||||||
// first parameter must be the image file.
|
// first parameter must be the image file.
|
||||||
if(argc == 0)
|
if (argc == 0)
|
||||||
{
|
{
|
||||||
goto print_help;
|
goto print_help;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_command(argv[0]))
|
if (is_command(argv[0]))
|
||||||
{
|
{
|
||||||
printf("Error: first parameter must be a filename, found '%s' instead. \n", argv[0]);
|
printf("Error: first parameter must be a filename, found '%s' instead. \n", argv[0]);
|
||||||
goto print_help;
|
goto print_help;
|
||||||
|
@ -104,7 +104,7 @@ int main(int oargc, char* oargv[])
|
||||||
|
|
||||||
imageFileName = argv[0];
|
imageFileName = argv[0];
|
||||||
|
|
||||||
if(disk_initialize(0))
|
if (disk_initialize(0))
|
||||||
{
|
{
|
||||||
printf("Error: could not open image file '%s'. \n", imageFileName);
|
printf("Error: could not open image file '%s'. \n", imageFileName);
|
||||||
goto print_help;
|
goto print_help;
|
||||||
|
@ -113,13 +113,13 @@ int main(int oargc, char* oargv[])
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
|
||||||
while(argc>0)
|
while (argc > 0)
|
||||||
{
|
{
|
||||||
char *parg = *argv;
|
char *parg = *argv;
|
||||||
|
|
||||||
if(!is_command(parg))
|
if (!is_command(parg))
|
||||||
{
|
{
|
||||||
printf("Error: Expected a command, found '%s' instead. \n",parg);
|
printf("Error: Expected a command, found '%s' instead. \n", parg);
|
||||||
goto print_help;
|
goto print_help;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,22 +129,22 @@ int main(int oargc, char* oargv[])
|
||||||
|
|
||||||
// find next command, to calculare number of args
|
// find next command, to calculare number of args
|
||||||
int nargs = 0;
|
int nargs = 0;
|
||||||
int i=0;
|
int i = 0;
|
||||||
while((argv[i] != NULL) && !is_command(argv[i++]))
|
while ((argv[i] != NULL) && !is_command(argv[i++]))
|
||||||
nargs++;
|
nargs++;
|
||||||
|
|
||||||
if(strcmp(parg,"format")==0)
|
if (strcmp(parg, "format") == 0)
|
||||||
{
|
{
|
||||||
// NOTE: The fs driver detects which FAT format fits best based on size
|
// NOTE: The fs driver detects which FAT format fits best based on size
|
||||||
|
|
||||||
NEED_PARAMS(1,1);
|
NEED_PARAMS(1, 1);
|
||||||
|
|
||||||
NEED_MOUNT();
|
NEED_MOUNT();
|
||||||
|
|
||||||
// Arg 1: number of sectors
|
// Arg 1: number of sectors
|
||||||
int sectors = atoi(argv[0]);
|
int sectors = atoi(argv[0]);
|
||||||
|
|
||||||
if(sectors <= 0)
|
if (sectors <= 0)
|
||||||
{
|
{
|
||||||
printf("Error: Sectors must be > 0\n");
|
printf("Error: Sectors must be > 0\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -159,16 +159,16 @@ int main(int oargc, char* oargv[])
|
||||||
goto print_help;
|
goto print_help;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(parg,"boot")==0)
|
else if (strcmp(parg, "boot") == 0)
|
||||||
{
|
{
|
||||||
NEED_PARAMS(1,1);
|
NEED_PARAMS(1, 1);
|
||||||
|
|
||||||
// Arg 1: boot file
|
// Arg 1: boot file
|
||||||
printf("Not Implemented.");
|
printf("Not Implemented.");
|
||||||
}
|
}
|
||||||
else if(strcmp(parg,"add")==0)
|
else if (strcmp(parg, "add") == 0)
|
||||||
{
|
{
|
||||||
NEED_PARAMS(2,2);
|
NEED_PARAMS(2, 2);
|
||||||
|
|
||||||
NEED_MOUNT();
|
NEED_MOUNT();
|
||||||
|
|
||||||
|
@ -176,14 +176,14 @@ int main(int oargc, char* oargv[])
|
||||||
// Arg 2: virtual filename
|
// Arg 2: virtual filename
|
||||||
|
|
||||||
FILE* fe;
|
FILE* fe;
|
||||||
FIL fv = {0};
|
FIL fv = { 0 };
|
||||||
|
|
||||||
if(fopen_s(&fe, argv[0],"rb"))
|
if (fopen_s(&fe, argv[0], "rb"))
|
||||||
{
|
{
|
||||||
printf("Error: unable to open external file '%s' for reading.", argv[0]);
|
printf("Error: unable to open external file '%s' for reading.", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(f_open(&fv, argv[1], FA_WRITE | FA_CREATE_ALWAYS))
|
if (f_open(&fv, argv[1], FA_WRITE | FA_CREATE_ALWAYS))
|
||||||
{
|
{
|
||||||
printf("Error: unable to open file '%s' for writing.", argv[1]);
|
printf("Error: unable to open file '%s' for writing.", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -193,32 +193,32 @@ int main(int oargc, char* oargv[])
|
||||||
UINT rdlen = 0;
|
UINT rdlen = 0;
|
||||||
UINT wrlen = 0;
|
UINT wrlen = 0;
|
||||||
|
|
||||||
while( (rdlen = fread(buff,1,32768,fe)) > 0 )
|
while ((rdlen = fread(buff, 1, 32768, fe)) > 0)
|
||||||
{
|
{
|
||||||
f_write(&fv,buff, rdlen, &wrlen);
|
f_write(&fv, buff, rdlen, &wrlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fe);
|
fclose(fe);
|
||||||
f_close(&fv);
|
f_close(&fv);
|
||||||
}
|
}
|
||||||
else if(strcmp(parg,"extract")==0)
|
else if (strcmp(parg, "extract") == 0)
|
||||||
{
|
{
|
||||||
NEED_PARAMS(2,2);
|
NEED_PARAMS(2, 2);
|
||||||
|
|
||||||
NEED_MOUNT();
|
NEED_MOUNT();
|
||||||
|
|
||||||
// Arg 1: virtual file to extract
|
// Arg 1: virtual file to extract
|
||||||
// Arg 2: external filename
|
// Arg 2: external filename
|
||||||
|
|
||||||
FIL fe = {0};
|
FIL fe = { 0 };
|
||||||
FILE* fv;
|
FILE* fv;
|
||||||
|
|
||||||
if(f_open(&fe, argv[0], FA_READ))
|
if (f_open(&fe, argv[0], FA_READ))
|
||||||
{
|
{
|
||||||
printf("Error: unable to open file '%s' for reading.", argv[0]);
|
printf("Error: unable to open file '%s' for reading.", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(fopen_s(&fv, argv[1],"wb"))
|
if (fopen_s(&fv, argv[1], "wb"))
|
||||||
{
|
{
|
||||||
printf("Error: unable to open external file '%s' for writing.", argv[1]);
|
printf("Error: unable to open external file '%s' for writing.", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -228,7 +228,7 @@ int main(int oargc, char* oargv[])
|
||||||
UINT rdlen = 0;
|
UINT rdlen = 0;
|
||||||
UINT wrlen = 0;
|
UINT wrlen = 0;
|
||||||
|
|
||||||
while( (f_read(&fe, buff, 32768, &rdlen) == 0 ) && ( rdlen > 0) )
|
while ((f_read(&fe, buff, 32768, &rdlen) == 0) && (rdlen > 0))
|
||||||
{
|
{
|
||||||
fwrite(buff, 1, rdlen, fv);
|
fwrite(buff, 1, rdlen, fv);
|
||||||
}
|
}
|
||||||
|
@ -236,34 +236,34 @@ int main(int oargc, char* oargv[])
|
||||||
f_close(&fe);
|
f_close(&fe);
|
||||||
fclose(fv);
|
fclose(fv);
|
||||||
}
|
}
|
||||||
else if(strcmp(parg,"move")==0)
|
else if (strcmp(parg, "move") == 0)
|
||||||
{
|
{
|
||||||
NEED_PARAMS(2,2);
|
NEED_PARAMS(2, 2);
|
||||||
|
|
||||||
NEED_MOUNT();
|
NEED_MOUNT();
|
||||||
// Arg 1: src path & filename
|
// Arg 1: src path & filename
|
||||||
// Arg 2: new path & filename
|
// Arg 2: new path & filename
|
||||||
|
|
||||||
if(f_rename(argv[0], argv[1]))
|
if (f_rename(argv[0], argv[1]))
|
||||||
printf("Error moving/renaming '%s' to '%s'", argv[0],argv[1]);
|
printf("Error moving/renaming '%s' to '%s'", argv[0], argv[1]);
|
||||||
}
|
}
|
||||||
else if(strcmp(parg,"copy")==0)
|
else if (strcmp(parg, "copy") == 0)
|
||||||
{
|
{
|
||||||
NEED_PARAMS(2,2)
|
NEED_PARAMS(2, 2);
|
||||||
|
|
||||||
NEED_MOUNT();
|
NEED_MOUNT();
|
||||||
// Arg 1: src path & filename
|
// Arg 1: src path & filename
|
||||||
// Arg 2: new path & filename
|
// Arg 2: new path & filename
|
||||||
|
|
||||||
FIL fe = {0};
|
FIL fe = { 0 };
|
||||||
FIL fv = {0};
|
FIL fv = { 0 };
|
||||||
|
|
||||||
if(f_open(&fe, argv[0], FA_READ))
|
if (f_open(&fe, argv[0], FA_READ))
|
||||||
{
|
{
|
||||||
printf("Error: unable to open file '%s' for reading.", argv[0]);
|
printf("Error: unable to open file '%s' for reading.", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(f_open(&fv, argv[1], FA_WRITE|FA_CREATE_ALWAYS))
|
if (f_open(&fv, argv[1], FA_WRITE | FA_CREATE_ALWAYS))
|
||||||
{
|
{
|
||||||
printf("Error: unable to open file '%s' for writing.", argv[1]);
|
printf("Error: unable to open file '%s' for writing.", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -273,7 +273,7 @@ int main(int oargc, char* oargv[])
|
||||||
UINT rdlen = 0;
|
UINT rdlen = 0;
|
||||||
UINT wrlen = 0;
|
UINT wrlen = 0;
|
||||||
|
|
||||||
while( (f_read(&fe, buff, 32768, &rdlen) == 0) && (rdlen > 0) )
|
while ((f_read(&fe, buff, 32768, &rdlen) == 0) && (rdlen > 0))
|
||||||
{
|
{
|
||||||
f_write(&fv, buff, rdlen, &wrlen);
|
f_write(&fv, buff, rdlen, &wrlen);
|
||||||
}
|
}
|
||||||
|
@ -281,51 +281,51 @@ int main(int oargc, char* oargv[])
|
||||||
f_close(&fe);
|
f_close(&fe);
|
||||||
f_close(&fv);
|
f_close(&fv);
|
||||||
}
|
}
|
||||||
else if(strcmp(parg,"mkdir")==0)
|
else if (strcmp(parg, "mkdir") == 0)
|
||||||
{
|
{
|
||||||
NEED_PARAMS(1,1);
|
NEED_PARAMS(1, 1);
|
||||||
|
|
||||||
NEED_MOUNT();
|
NEED_MOUNT();
|
||||||
// Arg 1: folder path
|
// Arg 1: folder path
|
||||||
f_mkdir(argv[1]);
|
f_mkdir(argv[1]);
|
||||||
}
|
}
|
||||||
else if(strcmp(parg,"delete")==0)
|
else if (strcmp(parg, "delete") == 0)
|
||||||
{
|
{
|
||||||
NEED_PARAMS(1,1);
|
NEED_PARAMS(1, 1);
|
||||||
|
|
||||||
NEED_MOUNT();
|
NEED_MOUNT();
|
||||||
// Arg 1: file/folder path (cannot delete non-empty folders)
|
// Arg 1: file/folder path (cannot delete non-empty folders)
|
||||||
f_unlink(argv[1]);
|
f_unlink(argv[1]);
|
||||||
}
|
}
|
||||||
else if(strcmp(parg,"list")==0)
|
else if (strcmp(parg, "list") == 0)
|
||||||
{
|
{
|
||||||
NEED_PARAMS(0,1);
|
NEED_PARAMS(0, 1);
|
||||||
|
|
||||||
// Arg 1: folder path (optional)
|
// Arg 1: folder path (optional)
|
||||||
char* root = "/";
|
char* root = "/";
|
||||||
|
|
||||||
if(nargs == 1)
|
if (nargs == 1)
|
||||||
{
|
{
|
||||||
root = argv[0];
|
root = argv[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
DIR dir = {0};
|
DIR dir = { 0 };
|
||||||
|
|
||||||
if(f_opendir(&dir, root))
|
if (f_opendir(&dir, root))
|
||||||
{
|
{
|
||||||
printf("Error opening directory '%s'.\n",root);
|
printf("Error opening directory '%s'.\n", root);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Listing directory contents of: %s\n", root);
|
printf("Listing directory contents of: %s\n", root);
|
||||||
|
|
||||||
FILINFO info = {0};
|
FILINFO info = { 0 };
|
||||||
CHAR lfname[257];
|
CHAR lfname[257];
|
||||||
info.lfname = lfname;
|
info.lfname = lfname;
|
||||||
info.lfsize = 256;
|
info.lfsize = 256;
|
||||||
while( (!f_readdir(&dir,&info)) && (strlen(info.fname)>0))
|
while ((!f_readdir(&dir, &info)) && (strlen(info.fname) > 0))
|
||||||
{
|
{
|
||||||
if(strlen(info.lfname) > 0)
|
if (strlen(info.lfname) > 0)
|
||||||
printf(" - %s (%s)\n", info.lfname, info.fname);
|
printf(" - %s (%s)\n", info.lfname, info.fname);
|
||||||
else
|
else
|
||||||
printf(" - %s\n", info.fname);
|
printf(" - %s\n", info.fname);
|
||||||
|
@ -333,11 +333,11 @@ int main(int oargc, char* oargv[])
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Error: Unknown or invalid command: %s\n",argv[-1]);
|
printf("Error: Unknown or invalid command: %s\n", argv[-1]);
|
||||||
goto print_help;
|
goto print_help;
|
||||||
}
|
}
|
||||||
argv+=nargs;
|
argv += nargs;
|
||||||
argc-=nargs;
|
argc -= nargs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue