Programme d'utilisation des AX12 avec rajout de l'MX12

Fork of test_carteAToutFaire_PR by CRAC Team

Committer:
R66Y
Date:
Sat May 20 15:23:58 2017 +0000
Revision:
3:1bb26049bdd1
Parent:
1:f3f702086a30
Programme de contr?le des AX12 avec rajout de l'MX12;

Who changed what in which revision?

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