This is my quadcopter prototype software, still in development!

Committer:
Anaesthetix
Date:
Tue Jul 23 14:01:42 2013 +0000
Revision:
1:ac68f0368a77
Parent:
0:978110f7f027
Other accelerometer added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anaesthetix 0:978110f7f027 1 /* mbed Microcontroller Library - FileSystemLike
Anaesthetix 0:978110f7f027 2 * Copyright (c) 2008-2009 ARM Limited. All rights reserved.
Anaesthetix 0:978110f7f027 3 */
Anaesthetix 0:978110f7f027 4
Anaesthetix 0:978110f7f027 5 #ifndef MBED_FILESYSTEMLIKE_H
Anaesthetix 0:978110f7f027 6 #define MBED_FILESYSTEMLIKE_H
Anaesthetix 0:978110f7f027 7
Anaesthetix 0:978110f7f027 8 #ifdef __ARMCC_VERSION
Anaesthetix 0:978110f7f027 9 # define O_RDONLY 0
Anaesthetix 0:978110f7f027 10 # define O_WRONLY 1
Anaesthetix 0:978110f7f027 11 # define O_RDWR 2
Anaesthetix 0:978110f7f027 12 # define O_CREAT 0x0200
Anaesthetix 0:978110f7f027 13 # define O_TRUNC 0x0400
Anaesthetix 0:978110f7f027 14 # define O_APPEND 0x0008
Anaesthetix 0:978110f7f027 15 typedef int mode_t;
Anaesthetix 0:978110f7f027 16 #else
Anaesthetix 0:978110f7f027 17 # include <sys/fcntl.h>
Anaesthetix 0:978110f7f027 18 #endif
Anaesthetix 0:978110f7f027 19 #include "Base.h"
Anaesthetix 0:978110f7f027 20 #include "FileHandle.h"
Anaesthetix 0:978110f7f027 21 #include "DirHandle.h"
Anaesthetix 0:978110f7f027 22
Anaesthetix 0:978110f7f027 23 namespace mbed {
Anaesthetix 0:978110f7f027 24
Anaesthetix 0:978110f7f027 25 /* Class FileSystemLike
Anaesthetix 0:978110f7f027 26 * A filesystem-like object is one that can be used to open files
Anaesthetix 0:978110f7f027 27 * though it by fopen("/name/filename", mode)
Anaesthetix 0:978110f7f027 28 *
Anaesthetix 0:978110f7f027 29 * Implementations must define at least open (the default definitions
Anaesthetix 0:978110f7f027 30 * of the rest of the functions just return error values).
Anaesthetix 0:978110f7f027 31 */
Anaesthetix 0:978110f7f027 32 class FileSystemLike : public Base {
Anaesthetix 0:978110f7f027 33
Anaesthetix 0:978110f7f027 34 public:
Anaesthetix 0:978110f7f027 35
Anaesthetix 0:978110f7f027 36 /* Constructor FileSystemLike
Anaesthetix 0:978110f7f027 37 *
Anaesthetix 0:978110f7f027 38 * Variables
Anaesthetix 0:978110f7f027 39 * name - The name to use for the filesystem.
Anaesthetix 0:978110f7f027 40 */
Anaesthetix 0:978110f7f027 41 FileSystemLike(const char *name) : Base(name) {}
Anaesthetix 0:978110f7f027 42
Anaesthetix 0:978110f7f027 43 /* Function open
Anaesthetix 0:978110f7f027 44 *
Anaesthetix 0:978110f7f027 45 * Variables
Anaesthetix 0:978110f7f027 46 * filename - The name of the file to open.
Anaesthetix 0:978110f7f027 47 * flags - One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with
Anaesthetix 0:978110f7f027 48 * zero or more of O_CREAT, O_TRUNC, or O_APPEND.
Anaesthetix 0:978110f7f027 49 * returns - A pointer to a FileHandle object representing the
Anaesthetix 0:978110f7f027 50 * file on success, or NULL on failure.
Anaesthetix 0:978110f7f027 51 */
Anaesthetix 0:978110f7f027 52 virtual FileHandle *open(const char *filename, int flags) = 0;
Anaesthetix 0:978110f7f027 53
Anaesthetix 0:978110f7f027 54 /* Function remove
Anaesthetix 0:978110f7f027 55 * Remove a file from the filesystem.
Anaesthetix 0:978110f7f027 56 *
Anaesthetix 0:978110f7f027 57 * Variables
Anaesthetix 0:978110f7f027 58 * filename - the name of the file to remove.
Anaesthetix 0:978110f7f027 59 * returns - 0 on success, -1 on failure.
Anaesthetix 0:978110f7f027 60 */
Anaesthetix 0:978110f7f027 61 virtual int remove(const char *filename) { return -1; };
Anaesthetix 0:978110f7f027 62
Anaesthetix 0:978110f7f027 63 /* Function rename
Anaesthetix 0:978110f7f027 64 * Rename a file in the filesystem.
Anaesthetix 0:978110f7f027 65 *
Anaesthetix 0:978110f7f027 66 * Variables
Anaesthetix 0:978110f7f027 67 * oldname - the name of the file to rename.
Anaesthetix 0:978110f7f027 68 * newname - the name to rename it to.
Anaesthetix 0:978110f7f027 69 * returns - 0 on success, -1 on failure.
Anaesthetix 0:978110f7f027 70 */
Anaesthetix 0:978110f7f027 71 virtual int rename(const char *oldname, const char *newname) { return -1; };
Anaesthetix 0:978110f7f027 72
Anaesthetix 0:978110f7f027 73 /* Function opendir
Anaesthetix 0:978110f7f027 74 * Opens a directory in the filesystem and returns a DirHandle
Anaesthetix 0:978110f7f027 75 * representing the directory stream.
Anaesthetix 0:978110f7f027 76 *
Anaesthetix 0:978110f7f027 77 * Variables
Anaesthetix 0:978110f7f027 78 * name - The name of the directory to open.
Anaesthetix 0:978110f7f027 79 * returns - A DirHandle representing the directory stream, or
Anaesthetix 0:978110f7f027 80 * NULL on failure.
Anaesthetix 0:978110f7f027 81 */
Anaesthetix 0:978110f7f027 82 virtual DirHandle *opendir(const char *name) { return NULL; };
Anaesthetix 0:978110f7f027 83
Anaesthetix 0:978110f7f027 84 /* Function mkdir
Anaesthetix 0:978110f7f027 85 * Creates a directory in the filesystem.
Anaesthetix 0:978110f7f027 86 *
Anaesthetix 0:978110f7f027 87 * Variables
Anaesthetix 0:978110f7f027 88 * name - The name of the directory to create.
Anaesthetix 0:978110f7f027 89 * mode - The permissions to create the directory with.
Anaesthetix 0:978110f7f027 90 * returns - 0 on success, -1 on failure.
Anaesthetix 0:978110f7f027 91 */
Anaesthetix 0:978110f7f027 92 virtual int mkdir(const char *name, mode_t mode) { return -1; }
Anaesthetix 0:978110f7f027 93
Anaesthetix 0:978110f7f027 94 // TODO other filesystem functions (mkdir, rm, rn, ls etc)
Anaesthetix 0:978110f7f027 95
Anaesthetix 0:978110f7f027 96 };
Anaesthetix 0:978110f7f027 97
Anaesthetix 0:978110f7f027 98 } // namespace mbed
Anaesthetix 0:978110f7f027 99
Anaesthetix 0:978110f7f027 100 #endif