1 /* mbed Microcontroller Library - LocalFileSystem
2 * Copyright (c) 2008-2009 ARM Limited. All rights reserved.
6 #ifndef MBED_LOCALFILESYSTEM_H
7 #define MBED_LOCALFILESYSTEM_H
9 #include "FileSystemLike.h"
13 /* Class: LocalFileSystem
14 * A filesystem for accessing the local mbed Microcontroller USB disk drive
16 * This allows programs to read and write files on the same disk drive that is used to program the
17 * mbed Microcontroller. Once created, the standard C file access functions are used to open,
18 * read and write files.
23 * > LocalFileSystem local("local"); // Create the local filesystem under the name "local"
26 * > FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing
27 * > fprintf(fp, "Hello World!");
29 * > remove("/local/out.txt"); // Removes the file "out.txt" from the local file system
31 * > DIR *d = opendir("/local"); // Opens the root directory of the local file system
33 * > while((p = readdir(d)) != NULL) { // Print the names of the files in the local file system
34 * > printf("%s\n", p->d_name); // to stdout.
39 * Implementation Notes:
40 * If the microcontroller program makes an access to the local drive, it will be marked as "removed"
41 * on the Host computer. This means it is no longer accessible from the Host Computer.
43 * The drive will only re-appear when the microcontroller program exists. Note that if the program does
44 * not exit, you will need to hold down reset on the mbed Microcontroller to be able to see the drive again!
46 class LocalFileSystem : public FileSystemLike {
50 LocalFileSystem(const char* n) : FileSystemLike(n) {
54 virtual FileHandle *open(const char* name, int flags);
55 virtual int remove(const char *filename);
56 virtual DirHandle *opendir(const char *name);