summaryrefslogtreecommitdiff
path: root/src/components/fs
diff options
context:
space:
mode:
authorTim Keller <geekboy1011@gmail.com>2021-10-17 16:04:23 +0000
committerTim Keller <geekboy1011@gmail.com>2021-12-10 01:18:57 +0000
commit91c644b43c250b0a03047349182828df31ddcbd2 (patch)
tree9feec7231acc3192468d281a8b091683efe14603 /src/components/fs
parentf57f797ff54d9ee8864d3fc62f0c8662df13aad8 (diff)
direcetory listings maybe?
Added LISTDIR command and notify responses.
Diffstat (limited to 'src/components/fs')
-rw-r--r--src/components/fs/FS.cpp63
-rw-r--r--src/components/fs/FS.h3
2 files changed, 38 insertions, 28 deletions
diff --git a/src/components/fs/FS.cpp b/src/components/fs/FS.cpp
index 1cad4f02..f287c28e 100644
--- a/src/components/fs/FS.cpp
+++ b/src/components/fs/FS.cpp
@@ -5,29 +5,28 @@
using namespace Pinetime::Controllers;
-FS::FS(Pinetime::Drivers::SpiNorFlash& driver) :
- flashDriver{ driver },
- lfsConfig{
- .context = this,
- .read = SectorRead,
- .prog = SectorProg,
- .erase = SectorErase,
- .sync = SectorSync,
-
- .read_size = 16,
- .prog_size = 8,
- .block_size = blockSize,
- .block_count = size / blockSize,
- .block_cycles = 1000u,
-
- .cache_size = 16,
- .lookahead_size = 16,
-
- .name_max = 50,
- .attr_max = 50,
- }
-{ }
-
+FS::FS(Pinetime::Drivers::SpiNorFlash& driver)
+ : flashDriver {driver},
+ lfsConfig {
+ .context = this,
+ .read = SectorRead,
+ .prog = SectorProg,
+ .erase = SectorErase,
+ .sync = SectorSync,
+
+ .read_size = 16,
+ .prog_size = 8,
+ .block_size = blockSize,
+ .block_count = size / blockSize,
+ .block_cycles = 1000u,
+
+ .cache_size = 16,
+ .lookahead_size = 16,
+
+ .name_max = 50,
+ .attr_max = 50,
+ } {
+}
void FS::Init() {
@@ -48,7 +47,6 @@ void FS::Init() {
VerifyResource();
LVGLFileSystemInit();
#endif
-
}
void FS::VerifyResource() {
@@ -56,7 +54,7 @@ void FS::VerifyResource() {
resourcesValid = true;
}
-int FS::FileOpen(lfs_file_t* file_p, const char* fileName, const int flags) {
+int FS::FileOpen(lfs_file_t* file_p, const char* fileName, const int flags) {
return lfs_file_open(&lfs, file_p, fileName, flags);
}
@@ -80,6 +78,17 @@ int FS::FileDelete(const char* fileName) {
return lfs_remove(&lfs, fileName);
}
+int FS::DirOpen(const char* path, lfs_dir_t* lfs_dir) {
+ return lfs_dir_open(&lfs, lfs_dir, path);
+}
+
+int FS::DirClose(lfs_dir_t* lfs_dir) {
+ return lfs_dir_close(&lfs, lfs_dir);
+}
+
+int FS::DirRead(lfs_dir_t* dir, lfs_info* info) {
+ return lfs_dir_read(&lfs, dir, info);
+}
int FS::DirCreate(const char* path) {
return lfs_mkdir(&lfs, path);
@@ -148,8 +157,7 @@ namespace {
if (file->type == 0) {
return LV_FS_RES_FS_ERR;
- }
- else {
+ } else {
return LV_FS_RES_OK;
}
}
@@ -193,5 +201,4 @@ void FS::LVGLFileSystemInit() {
fs_drv.user_data = this;
lv_fs_drv_register(&fs_drv);
-
} \ No newline at end of file
diff --git a/src/components/fs/FS.h b/src/components/fs/FS.h
index 75ba16c8..28d28d3c 100644
--- a/src/components/fs/FS.h
+++ b/src/components/fs/FS.h
@@ -21,6 +21,9 @@ namespace Pinetime {
int FileDelete(const char* fileName);
+ int DirOpen(const char* path, lfs_dir_t* lfs_dir);
+ int DirClose(lfs_dir_t* lfs_dir);
+ int DirRead(lfs_dir_t* dir, lfs_info* info);
int DirCreate(const char* path);
int DirDelete(const char* path);