complete nffs libraries

This commit is contained in:
hathach committed 2017-02-28 23:28:14 +07:00
1 parent be7a784586
commit 8906b84913
5 files changed
+37 -4

No files matched your search

@@ -21,7 +21,8 @@
NffsFile file;
// the setup function runs once when you press reset or power the board
void setup() {
void setup()
{
Serial.begin(115200);
Serial.println("nffs example");
+19 -1
View File
@@ -40,10 +40,28 @@ NewtNffs Nffs;
NewtNffs::NewtNffs(void)
{
errnum = FS_EOK;
}
void NewtNffs::begin(void)
{
nffs_pkg_init();
}
bool NewtNffs::mkdir(const char* path)
{
errnum = fs_mkdir(path);
return (errnum == FS_EOK);
}
bool NewtNffs::remove(const char* path)
{
errnum = fs_unlink(path);
return (errnum == FS_EOK);
}
bool NewtNffs::rename(const char* from, const char* to)
{
errnum = fs_rename(from, to);
return (errnum == FS_EOK);
}
+13
View File
@@ -46,9 +46,22 @@
class NewtNffs
{
public:
int errnum;
NewtNffs(void);
void begin(void);
// Make a directory (and its parents if not existed) a.k.a mkdir -p
bool mkdir(const char* path);
// Remove a file or an empty directory
bool remove(const char* path);
bool rm (const char* path) { return remove(path); }
// Remove a non-readonly file or an empty directory
bool rename(const char* from, const char* to);
bool mv (const char* from, const char* to) { return rename(from, to); }
};
+2 -1
View File
@@ -38,7 +38,8 @@
void NffsDir::_init(void)
{
_dir = NULL;
_dir = NULL;
errnum = FS_EOK;
}
NffsDir::NffsDir(void)
+1 -1
View File
@@ -39,7 +39,7 @@
void NffsFile::_init(void)
{
_file = NULL;
errnum = 0;
errnum = FS_EOK;
}
NffsFile::NffsFile(void)