Skip to content

Commit c0c87b0

Browse files
committed
Add a rename(oldfilename, newfilename) method to LittleFS class
1 parent b03d6e5 commit c0c87b0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

libraries/Adafruit_LittleFS/src/Adafruit_LittleFS.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ bool Adafruit_LittleFS::remove (char const *filepath)
195195
return LFS_ERR_OK == err;
196196
}
197197

198+
// Rename a file
199+
bool Adafruit_LittleFS::rename (char const *oldfilepath, char const *newfilepath)
200+
{
201+
_lockFS();
202+
203+
int err = lfs_rename(&_lfs, oldfilepath, newfilepath);
204+
PRINT_LFS_ERR(err);
205+
206+
_unlockFS();
207+
return LFS_ERR_OK == err;
208+
}
209+
198210
// Remove a folder
199211
bool Adafruit_LittleFS::rmdir (char const *filepath)
200212
{

libraries/Adafruit_LittleFS/src/Adafruit_LittleFS.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class Adafruit_LittleFS
5858
// Delete the file.
5959
bool remove (char const *filepath);
6060

61+
// Rename the file.
62+
bool rename (char const *oldfilepath, char const *newfilepath);
63+
6164
// Delete a folder (must be empty)
6265
bool rmdir (char const *filepath);
6366

0 commit comments

Comments
 (0)