add Nffs listDir() and catFile()

This commit is contained in:
hathach committed 2018-01-15 14:52:52 +07:00
1 parent f05eb8e15b
commit 9ac36417d1
2 files changed
+24

No files matched your search

+23
View File
@@ -204,6 +204,7 @@ void ApacheNffs::listDir(const char* cwd)
{
// Open the input folder
NffsDir dir(cwd);
VERIFY ( dir.exists(), );
// File Entry Information which hold file attribute and name
NffsDirEntry dirEntry;
@@ -232,3 +233,25 @@ void ApacheNffs::listDir(const char* cwd)
dir.close();
}
void ApacheNffs::catFile(const char* fpath, bool isText)
{
NffsFile f(fpath, FS_ACCESS_READ);
VERIFY ( f.exists(), );
uint8_t buffer[128];
uint32_t count;
while ( (count = f.read(buffer, sizeof(buffer))) > 0 )
{
if ( isText )
{
Serial.write(buffer, count);
}else
{
dbgDumpMemory(buffer, 1, count, true);
}
}
f.close();
}
+1
View File
@@ -86,6 +86,7 @@ public:
}
void listDir(const char* cwd);
void catFile(const char* fpath, bool isText = false);
};