re-enabling serial
[clinton/Smoothieware.git] / gcc4mbed / external / mbed / .svn / text-base / LocalFileSystem.h.svn-base
1 /* mbed Microcontroller Library - LocalFileSystem
2 * Copyright (c) 2008-2009 ARM Limited. All rights reserved.
3 * sford
4 */
5
6 #ifndef MBED_LOCALFILESYSTEM_H
7 #define MBED_LOCALFILESYSTEM_H
8
9 #include "FileSystemLike.h"
10
11 namespace mbed {
12
13 /* Class: LocalFileSystem
14 * A filesystem for accessing the local mbed Microcontroller USB disk drive
15 *
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.
19 *
20 * Example:
21 * > #include "mbed.h"
22 * >
23 * > LocalFileSystem local("local"); // Create the local filesystem under the name "local"
24 * >
25 * > int main() {
26 * > FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing
27 * > fprintf(fp, "Hello World!");
28 * > fclose(fp);
29 * > remove("/local/out.txt"); // Removes the file "out.txt" from the local file system
30 * >
31 * > DIR *d = opendir("/local"); // Opens the root directory of the local file system
32 * > struct dirent *p;
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.
35 * > }
36 * > closedir(d);
37 * > }
38 *
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.
42 *
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!
45 */
46 class LocalFileSystem : public FileSystemLike {
47
48 public:
49
50 LocalFileSystem(const char* n) : FileSystemLike(n) {
51
52 }
53
54 virtual FileHandle *open(const char* name, int flags);
55 virtual int remove(const char *filename);
56 virtual DirHandle *opendir(const char *name);
57 };
58
59 } // namespace mbed
60
61 #endif