Skip to content

Commit 709c3bc

Browse files
committed
New FileSystem API
1 parent f09f6e0 commit 709c3bc

10 files changed

Lines changed: 356 additions & 320 deletions

File tree

Applications/MSC/MSC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "USB/USB.h"
44

55
void MSC::Setup() {
6-
if (!MatrixOS::File::Available()) {
6+
if (!Device::Storage::Available()) {
77
MLOGW("MSC", "Storage not available - cannot enter USB storage mode");
88
Exit();
99
return;

Applications/Setting/Setting.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ void Setting::Start() {
5757
mscModeBtn.SetName("USB Storage Mode");
5858
mscModeBtn.SetSize(Dimension(1, 1));
5959
mscModeBtn.OnPress([]() -> void {
60-
if (MatrixOS::File::Available()) {
60+
if (Device::Storage::Available()) {
6161
MatrixOS::SYS::ExecuteAPP("203 Systems", "MSC Mode");
6262
}
6363
});
6464

6565
// Dynamic color based on storage availability
6666
mscModeBtn.SetColorFunc([]() -> Color {
67-
return Color(0xFF8000).DimIfNot(MatrixOS::File::Available());
67+
return Color(0xFF8000).DimIfNot(Device::Storage::Available());
6868
});
6969

7070
AddUIComponent(mscModeBtn, Point(Device::x_size - 1, Device::y_size - 1));

Applications/Shell/Shell.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void Shell::Setup()
3939
InitializeFolderSystem();
4040

4141
// Test filesystem functionality - DISABLED to prevent conflicts with USB MSC
42-
// TestFileSystem();
42+
TestFileSystem();
4343
}
4444

4545
void Shell::Loop() {
@@ -69,21 +69,23 @@ void Shell::TestFileSystem() {
6969
string test_content = "MatrixOS Filesystem Test\nTimestamp: ";
7070
test_content += std::to_string(Device::Micros());
7171

72-
// Test file write using low-level API
73-
MatrixOS::File::File* file = MatrixOS::File::Open(test_file, FA_WRITE | FA_CREATE_ALWAYS);
72+
// Test file write using new File API
73+
File* file = MatrixOS::FileSystem::Open(test_file, "w");
7474
if (file) {
75-
size_t written = MatrixOS::File::Write(file, test_content.c_str(), test_content.length());
76-
MatrixOS::File::Close(file);
75+
size_t written = file->Write(test_content.c_str(), test_content.length());
76+
file->Close();
77+
delete file;
7778

7879
if (written == test_content.length()) {
7980
MLOGD("Shell", "File write test: PASS");
8081

8182
// Test file read
82-
file = MatrixOS::File::Open(test_file, FA_READ);
83+
file = MatrixOS::FileSystem::Open(test_file, "r");
8384
if (file) {
8485
char read_buffer[256];
85-
size_t read_bytes = MatrixOS::File::Read(file, read_buffer, sizeof(read_buffer));
86-
MatrixOS::File::Close(file);
86+
size_t read_bytes = file->Read(read_buffer, sizeof(read_buffer));
87+
file->Close();
88+
delete file;
8789

8890
if (read_bytes == test_content.length()) {
8991
string read_content(read_buffer, read_bytes);
@@ -100,7 +102,7 @@ void Shell::TestFileSystem() {
100102
}
101103

102104
// Test file deletion
103-
if (MatrixOS::File::Delete(test_file)) {
105+
if (MatrixOS::FileSystem::Remove(test_file)) {
104106
MLOGD("Shell", "File delete test: PASS");
105107
} else {
106108
MLOGE("Shell", "File delete test: FAIL");
@@ -114,11 +116,11 @@ void Shell::TestFileSystem() {
114116

115117
// Test directory operations
116118
string test_dir = "/test_dir";
117-
if (MatrixOS::File::CreateDir(test_dir)) {
119+
if (MatrixOS::FileSystem::MakeDir(test_dir)) {
118120
MLOGD("Shell", "Directory create test: PASS");
119121

120122
// Test directory deletion
121-
if (MatrixOS::File::Delete(test_dir)) {
123+
if (MatrixOS::FileSystem::RemoveDir(test_dir)) {
122124
MLOGD("Shell", "Directory delete test: PASS");
123125
} else {
124126
MLOGE("Shell", "Directory delete test: FAIL");

OS/FileSystem/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
file(GLOB_RECURSE FILE_HEADERS "*.h")
22
set(FILE_SOURCES
33
File.cpp
4+
FileSystem.cpp
45
)
56

67
# Local FatFS sources

0 commit comments

Comments
 (0)