Skip to content

Commit 8abf80c

Browse files
authored
feat(file_system): Update example to include built+bundled file system (#268)
* feat(file_system): Update example to include built+bundled file system * readme: update
1 parent e3757ed commit 8abf80c

File tree

8 files changed

+16
-4
lines changed

8 files changed

+16
-4
lines changed

components/file_system/example/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ See the Getting Started Guide for full steps to configure and use ESP-IDF to bui
2626

2727
## Example Output
2828

29-
![CleanShot 2024-07-01 at 13 57 50](https://github.com/esp-cpp/espp/assets/213467/dd45e8eb-6927-403b-a889-86274cfeeb76)
29+
![CleanShot 2024-07-02 at 10 09 29](https://github.com/esp-cpp/espp/assets/213467/02fab9cb-ec32-4ff5-93c9-1da7945ed2fc)
3030

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world!
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
idf_component_register(SRC_DIRS "."
22
INCLUDE_DIRS ".")
3+
4+
# Note: you must have a partition named the first argument (here it's "littlefs")
5+
# in your partition table csv file.
6+
littlefs_create_partition_image(littlefs ../files FLASH_IN_PROJECT)

components/file_system/src/file_system.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,14 @@ std::string FileSystem::list_directory(const std::string &path, const ListConfig
215215
if (config.date_time) {
216216
result += fmt::format("{:>12} ", get_file_time_as_string(file_path));
217217
}
218-
result += prefix;
219-
result += entry->d_name;
218+
std::string relative_name = "";
219+
if (prefix.size())
220+
relative_name += prefix + "/";
221+
relative_name += entry->d_name;
222+
result += relative_name;
220223
result += "\r\n";
221224
if (config.recursive && fs::is_directory(file_status)) {
222-
result += list_directory(file_path, config, std::string{entry->d_name} + "/");
225+
result += list_directory(file_path, config, relative_name);
223226
}
224227
}
225228
closedir(dir);

0 commit comments

Comments
 (0)