Wiljan Arias / WhexReefMonitor

Dependencies:   mbed-rtos EthernetInterface FatFileSystemCpp MCP23S17 SDFileSystem mbed

Fork of HTTPServerHelloWorld by Donatien Garnier

Committer:
wyunreal
Date:
Fri Jan 31 23:19:28 2014 +0000
Revision:
3:5dc0023e6284
First approach of EthernetService class

Who changed what in which revision?

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