diff --git a/example/sdkconfig.defaults b/example/sdkconfig.defaults index 24e16f0..ab47bde 100644 --- a/example/sdkconfig.defaults +++ b/example/sdkconfig.defaults @@ -1,2 +1,12 @@ CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_demo_esp_littlefs.csv" + +# +# Serial flasher config +# +CONFIG_ESPTOOLPY_BAUD_921600B=y +CONFIG_ESPTOOLPY_COMPRESSED=y +CONFIG_ESPTOOLPY_MONITOR_BAUD_CONSOLE=y + +# BOOTLOADER +CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y diff --git a/src/esp_littlefs.c b/src/esp_littlefs.c index ff2b590..89f62fc 100644 --- a/src/esp_littlefs.c +++ b/src/esp_littlefs.c @@ -1415,15 +1415,28 @@ static int vfs_littlefs_rename(void* ctx, const char *src, const char *dst) { return -1; } +#if CONFIG_LITTLEFS_SPIFFS_COMPAT + /* Create all parent directories to dst (if necessary) */ + ESP_LOGV(TAG, "LITTLEFS_SPIFFS_COMPAT attempting to create all directories for %s", src); + mkdirs(efs, dst); +#endif + res = lfs_rename(efs->fs, src, dst); - sem_give(efs); if (res < 0) { errno = lfs_errno_remap(res); + sem_give(efs); ESP_LOGV(TAG, "Failed to rename \"%s\" -> \"%s\". Error %s (%d)", src, dst, esp_littlefs_errno(res), res); return -1; } +#if CONFIG_LITTLEFS_SPIFFS_COMPAT + /* Attempt to delete all parent directories from src that are empty */ + rmdirs(efs, src); +#endif // CONFIG_LITTLEFS_SPIFFS_COMPAT + + sem_give(efs); + return 0; }