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