/* flaneth - flash and ethernet
Copyright (C) 2007-2012 Stefan Schuermans <stefan@schuermans.info>
Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html
a BlinkenArea project - http://www.blinkenarea.org/ */
#include <string.h>
#include "app_cfg.h"
#include "apps.h"
#include "debug.h"
#include "dosfs.h"
/**
* @brief list directory and dump file
* @param[in] sectorBuf scratch buffer to store a sector
* @param[in] vi volume information structure
*/
static void AppsListDump(uint8_t sectorBuf[SECTOR_SIZE], VOLINFO *vi)
{
DIRINFO di;
DIRENT de;
uint8_t filename[12];
FILEINFO fi;
uint8_t buf[64];
uint32_t len, i;
// list files in root directory
di.scratch = sectorBuf;
if (DFS_OpenDir(vi, (uint8_t *)"", &di) != 0) {
debug_apps_printf("cannot open root directory");
return;
}
debug_apps_printf("files in root directory:");
while (DFS_GetNext(vi, &di, &de) == 0) {
if (de.attr == ATTR_LONG_NAME) {
// ignore long names
} else if (de.attr & ATTR_VOLUME_ID) {
debug_apps_printf("volume ID: %-11.11s", de.name);
} else if (de.attr & ATTR_DIRECTORY) {
debug_apps_printf("directory: %-11.11s", de.name);
} else {
debug_apps_printf("file: %-11.11s", de.name);
memcpy(filename, de.name, 11); // remember last filename
filename[11] = 0;
}
}
// dump last file
if (DFS_OpenFile(vi, filename, DFS_READ, sectorBuf, &fi) != 0) {
debug_apps_printf("cannot open file %s", filename);
return;