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 - DirHandler
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_DIRHANDLE_H
wyunreal 3:5dc0023e6284 7 #define MBED_DIRHANDLE_H
wyunreal 3:5dc0023e6284 8
wyunreal 3:5dc0023e6284 9 #ifdef __ARMCC_VERSION
wyunreal 3:5dc0023e6284 10 # define NAME_MAX 255
wyunreal 3:5dc0023e6284 11 typedef int mode_t;
wyunreal 3:5dc0023e6284 12 #else
wyunreal 3:5dc0023e6284 13 # include <sys/syslimits.h>
wyunreal 3:5dc0023e6284 14 #endif
wyunreal 3:5dc0023e6284 15 #include "FileHandle.h"
wyunreal 3:5dc0023e6284 16
wyunreal 3:5dc0023e6284 17 struct dirent {
wyunreal 3:5dc0023e6284 18 char d_name[NAME_MAX+1];
wyunreal 3:5dc0023e6284 19 };
wyunreal 3:5dc0023e6284 20
wyunreal 3:5dc0023e6284 21 namespace mbed {
wyunreal 3:5dc0023e6284 22
wyunreal 3:5dc0023e6284 23 /* Class DirHandle
wyunreal 3:5dc0023e6284 24 * Represents a directory stream. Objects of this type are returned
wyunreal 3:5dc0023e6284 25 * by a FileSystemLike's opendir method. Implementations must define
wyunreal 3:5dc0023e6284 26 * at least closedir, readdir and rewinddir.
wyunreal 3:5dc0023e6284 27 *
wyunreal 3:5dc0023e6284 28 * If a FileSystemLike class defines the opendir method, then the
wyunreal 3:5dc0023e6284 29 * directories of an object of that type can be accessed by
wyunreal 3:5dc0023e6284 30 * DIR *d = opendir("/example/directory") (or opendir("/example")
wyunreal 3:5dc0023e6284 31 * to open the root of the filesystem), and then using readdir(d) etc.
wyunreal 3:5dc0023e6284 32 *
wyunreal 3:5dc0023e6284 33 * The root directory is considered to contain all FileLike and
wyunreal 3:5dc0023e6284 34 * FileSystemLike objects, so the DIR* returned by opendir("/") will
wyunreal 3:5dc0023e6284 35 * reflect this.
wyunreal 3:5dc0023e6284 36 */
wyunreal 3:5dc0023e6284 37 class DirHandle {
wyunreal 3:5dc0023e6284 38
wyunreal 3:5dc0023e6284 39 public:
wyunreal 3:5dc0023e6284 40 /* Function closedir
wyunreal 3:5dc0023e6284 41 * Closes the directory.
wyunreal 3:5dc0023e6284 42 *
wyunreal 3:5dc0023e6284 43 * Variables
wyunreal 3:5dc0023e6284 44 * returns - 0 on success, or -1 on error.
wyunreal 3:5dc0023e6284 45 */
wyunreal 3:5dc0023e6284 46 virtual int closedir()=0;
wyunreal 3:5dc0023e6284 47
wyunreal 3:5dc0023e6284 48 /* Function readdir
wyunreal 3:5dc0023e6284 49 * Return the directory entry at the current position, and
wyunreal 3:5dc0023e6284 50 * advances the position to the next entry.
wyunreal 3:5dc0023e6284 51 *
wyunreal 3:5dc0023e6284 52 * Returns
wyunreal 3:5dc0023e6284 53 * A pointer to a dirent structure representing the
wyunreal 3:5dc0023e6284 54 * directory entry at the current position, or NULL on reaching
wyunreal 3:5dc0023e6284 55 * end of directory or error.
wyunreal 3:5dc0023e6284 56 */
wyunreal 3:5dc0023e6284 57 virtual struct dirent *readdir()=0;
wyunreal 3:5dc0023e6284 58
wyunreal 3:5dc0023e6284 59 /* Function rewinddir
wyunreal 3:5dc0023e6284 60 * Resets the position to the beginning of the directory.
wyunreal 3:5dc0023e6284 61 */
wyunreal 3:5dc0023e6284 62 virtual void rewinddir()=0;
wyunreal 3:5dc0023e6284 63
wyunreal 3:5dc0023e6284 64 /* Function telldir
wyunreal 3:5dc0023e6284 65 * Returns the current position of the DirHandle.
wyunreal 3:5dc0023e6284 66 *
wyunreal 3:5dc0023e6284 67 * Returns
wyunreal 3:5dc0023e6284 68 * The current position, or -1 on error.
wyunreal 3:5dc0023e6284 69 */
wyunreal 3:5dc0023e6284 70 virtual off_t telldir() { return -1; }
wyunreal 3:5dc0023e6284 71
wyunreal 3:5dc0023e6284 72 /* Function seekdir
wyunreal 3:5dc0023e6284 73 * Sets the position of the DirHandle.
wyunreal 3:5dc0023e6284 74 *
wyunreal 3:5dc0023e6284 75 * Variables
wyunreal 3:5dc0023e6284 76 * location - The location to seek to. Must be a value returned
wyunreal 3:5dc0023e6284 77 * by telldir.
wyunreal 3:5dc0023e6284 78 */
wyunreal 3:5dc0023e6284 79 virtual void seekdir(off_t location) { }
wyunreal 3:5dc0023e6284 80
wyunreal 3:5dc0023e6284 81 };
wyunreal 3:5dc0023e6284 82
wyunreal 3:5dc0023e6284 83 } // namespace mbed
wyunreal 3:5dc0023e6284 84
wyunreal 3:5dc0023e6284 85 typedef mbed::DirHandle DIR;
wyunreal 3:5dc0023e6284 86
wyunreal 3:5dc0023e6284 87 extern "C" {
wyunreal 3:5dc0023e6284 88 DIR *opendir(const char*);
wyunreal 3:5dc0023e6284 89 struct dirent *readdir(DIR *);
wyunreal 3:5dc0023e6284 90 int closedir(DIR*);
wyunreal 3:5dc0023e6284 91 void rewinddir(DIR*);
wyunreal 3:5dc0023e6284 92 long telldir(DIR*);
wyunreal 3:5dc0023e6284 93 void seekdir(DIR*, long);
wyunreal 3:5dc0023e6284 94 int mkdir(const char *name, mode_t n);
wyunreal 3:5dc0023e6284 95 };
wyunreal 3:5dc0023e6284 96
wyunreal 3:5dc0023e6284 97 #endif /* MBED_DIRHANDLE_H */