Skip to content

Commit 219cb19

Browse files
committed
Update SPIFFS wrapper for 0.3.3
1 parent d2d1bef commit 219cb19

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

cores/esp8266/spiffs_api.cpp

+5-17
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ class SPIFFSImpl : public FSImpl {
6363
DirImplPtr openDir(const char* path) override;
6464

6565
bool rename(const char* pathFrom, const char* pathTo) override {
66-
char tmpNameFrom[SPIFFS_OBJ_NAME_LEN];
67-
strlcpy(tmpNameFrom, pathFrom, sizeof(tmpNameFrom));
68-
char tmpNameTo[SPIFFS_OBJ_NAME_LEN];
69-
strlcpy(tmpNameTo, pathTo, sizeof(tmpNameTo));
70-
auto rc = SPIFFS_rename(&_fs, tmpNameFrom, tmpNameTo);
66+
auto rc = SPIFFS_rename(&_fs, pathFrom, pathTo);
7167
if (rc != SPIFFS_OK) {
7268
DEBUGV("SPIFFS_rename: rc=%d, from=`%s`, to=`%s`\r\n", rc,
7369
pathFrom, pathTo);
@@ -86,9 +82,7 @@ class SPIFFSImpl : public FSImpl {
8682
}
8783

8884
bool remove(const char* path) override {
89-
char tmpName[SPIFFS_OBJ_NAME_LEN];
90-
strlcpy(tmpName, path, sizeof(tmpName));
91-
auto rc = SPIFFS_remove(&_fs, tmpName);
85+
auto rc = SPIFFS_remove(&_fs, path);
9286
if (rc != SPIFFS_OK) {
9387
DEBUGV("SPIFFS_remove: rc=%d path=`%s`\r\n", rc, path);
9488
return false;
@@ -411,9 +405,7 @@ class SPIFFSDirImpl : public DirImpl {
411405

412406
FileImplPtr SPIFFSImpl::open(const char* path, OpenMode openMode, AccessMode accessMode) {
413407
int mode = getSpiffsMode(openMode, accessMode);
414-
char tmpName[SPIFFS_OBJ_NAME_LEN];
415-
strlcpy(tmpName, path, sizeof(tmpName));
416-
int fd = SPIFFS_open(&_fs, tmpName, mode, 0);
408+
int fd = SPIFFS_open(&_fs, path, mode, 0);
417409
if (fd < 0) {
418410
DEBUGV("SPIFFSImpl::open: fd=%d path=`%s` openMode=%d accessMode=%d err=%d\r\n",
419411
fd, path, openMode, accessMode, _fs.err_code);
@@ -423,18 +415,14 @@ FileImplPtr SPIFFSImpl::open(const char* path, OpenMode openMode, AccessMode acc
423415
}
424416

425417
bool SPIFFSImpl::exists(const char* path) {
426-
char tmpName[SPIFFS_OBJ_NAME_LEN];
427-
strlcpy(tmpName, path, sizeof(tmpName));
428418
spiffs_stat stat;
429-
int rc = SPIFFS_stat(&_fs, tmpName, &stat);
419+
int rc = SPIFFS_stat(&_fs, path, &stat);
430420
return rc == SPIFFS_OK;
431421
}
432422

433423
DirImplPtr SPIFFSImpl::openDir(const char* path) {
434424
spiffs_DIR dir;
435-
char tmpName[SPIFFS_OBJ_NAME_LEN];
436-
strlcpy(tmpName, path, sizeof(tmpName));
437-
spiffs_DIR* result = SPIFFS_opendir(&_fs, tmpName, &dir);
425+
spiffs_DIR* result = SPIFFS_opendir(&_fs, path, &dir);
438426
if (!result) {
439427
DEBUGV("SPIFFSImpl::openDir: path=`%s` err=%d\r\n", path, _fs.err_code);
440428
return DirImplPtr();

0 commit comments

Comments
 (0)