API Reference
File System API
File Writing
An example of writing a file to a LittleFS file system:
CMakeLists.txt's end should include:
target_link_libraries(fs-flash jxglib_LFS_Flash)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../pico-jxglib pico-jxglib)
Edit the source file as follows:
LFS::Flash drive("Drive", 0x0004'0000); // 256kBCreates a LittleFS file system drive namedDrivewith 256kB sizeif (!FS::Mount("Drive:") && !FS::Format(Stdio::Instance, "Drive:")) return 1;Checks if the drive is mounted. If not, formats the driveFile* pFile = FS::OpenFile("Drive:/test.txt", "w");Opens a file for writingpFile->Printf("Line %d\n", i + 1);Writes a line to the filepFile->Close();Closes the filedelete pFile;Deletes the file pointer
The same operations are possible with FAT file systems.
File Reading
An example of reading a file from a LittleFS file system:
CMakeLists.txt's end should include:
target_link_libraries(fs-flash jxglib_LFS_Flash)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../pico-jxglib pico-jxglib)
Edit the source file as follows:
File* pFile = FS::OpenFile("Drive:/test.txt", "r");Opens a file for readingpFile->ReadLine(line, sizeof(line))Reads a line from the file
Directory Information
An example of getting directory information from a LittleFS file system:
CMakeLists.txt's end should include:
target_link_libraries(fs-flash jxglib_LFS_Flash)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../pico-jxglib pico-jxglib)
Edit the source file as follows:
FS::Dir* pDir = FS::OpenDir("Drive:/");Opens a directorypFileInfo = pDir->Read()Reads file information into an FS::FileInfo instancepDir->Close();Closes the directory
API Reference
FS::CopyFile
Copies a file
FS::Move
Renames or moves a file or directory (directory moving is not supported)
FS::RemoveFile
Deletes a file
FS::RemoveDir
Deletes a directory
FS::CreateDir
Creates a directory
FS::ChangeCurDir
Changes the current directory
FS::Format
Formats the file system
FS::Mount
Mounts the file system
FS::Unmount
Unmounts the file system