Demo to read and write to both SD and USB File System
Example (more detailed example in the main.cpp file):
#include "mbed.h" #include "MSCFileSystem.h" #include "SDFileSystem.h" MSCFileSystem fs("fs"); SDFileSystem sd(p5, p6, p7, p8, "sd", p11, SDFileSystem::SWITCH_NEG_NO, 15000000); // CAUTION: Return values should ALWAYS be checked. Not shown here for brevity. int main() { ... FileHandle * sdfile = sd.open("test.txt", O_WRONLY | O_CREAT | O_TRUNC); sdfile->write("hello", 6); sdfile->close(); ... FILE * file = fopen("nextest.txt", "w"); fwrite(buffer, 1, sizeof(buffer), file); fclose(file); ... mkdir("/sd/sd_dir", 0777); mkdir("/fs/fs_dir", 0777); remove("/sd/sdfinal.log"); rename("/sd/sdfinal.txt", "/sd/sdfinal.log"); ... }
Changes
Revision | Date | Who | Commit message |
---|---|---|---|
6:ea80c5a132b6 | 2016-03-13 | WiredHome | Example using Multi-FileSystem (which permits access to a USB Flash and an SD card from one application). |
5:2584287350fc | 2016-03-13 | WiredHome | Integrated both the SD and the USB File System drivers to permit both to be used. |
4:be096a44f789 | 2016-03-13 | WiredHome | Support longer filenames |
3:a72f30142261 | 2016-03-13 | WiredHome | Changed to support simultaneous SD and USB FileSystem |
2:c887cf1c3ed9 | 2012-10-16 | chris | Adapted from USBFlashDiskTest |
1:1f7a5d9bf5f7 | 2012-07-23 | chris | Includes the library with updated .c to .cpp file names |
0:22a5db2c7926 | 2012-07-23 | chris | Working with new Compiler repos; |