complete nffs libraries
This commit is contained in:
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");
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@
|
||||
|
||||
void NffsDir::_init(void)
|
||||
{
|
||||
_dir = NULL;
|
||||
_dir = NULL;
|
||||
errnum = FS_EOK;
|
||||
}
|
||||
|
||||
NffsDir::NffsDir(void)
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
void NffsFile::_init(void)
|
||||
{
|
||||
_file = NULL;
|
||||
errnum = 0;
|
||||
errnum = FS_EOK;
|
||||
}
|
||||
|
||||
NffsFile::NffsFile(void)
|
||||
|
||||
Reference in new issue
Block a user