Programme d'utilisation des AX12 avec rajout de l'MX12
Fork of test_carteAToutFaire_PR by
mbed/FileSystemLike.h@1:f3f702086a30, 2017-05-11 (annotated)
- Committer:
- ClementBreteau
- Date:
- Thu May 11 11:49:50 2017 +0000
- Revision:
- 1:f3f702086a30
test de la carte ? tout faire du petit robot
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ClementBreteau | 1:f3f702086a30 | 1 | /* mbed Microcontroller Library - FileSystemLike |
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_FILESYSTEMLIKE_H |
ClementBreteau | 1:f3f702086a30 | 6 | #define MBED_FILESYSTEMLIKE_H |
ClementBreteau | 1:f3f702086a30 | 7 | |
ClementBreteau | 1:f3f702086a30 | 8 | #ifdef __ARMCC_VERSION |
ClementBreteau | 1:f3f702086a30 | 9 | # define O_RDONLY 0 |
ClementBreteau | 1:f3f702086a30 | 10 | # define O_WRONLY 1 |
ClementBreteau | 1:f3f702086a30 | 11 | # define O_RDWR 2 |
ClementBreteau | 1:f3f702086a30 | 12 | # define O_CREAT 0x0200 |
ClementBreteau | 1:f3f702086a30 | 13 | # define O_TRUNC 0x0400 |
ClementBreteau | 1:f3f702086a30 | 14 | # define O_APPEND 0x0008 |
ClementBreteau | 1:f3f702086a30 | 15 | typedef int mode_t; |
ClementBreteau | 1:f3f702086a30 | 16 | #else |
ClementBreteau | 1:f3f702086a30 | 17 | # include <sys/fcntl.h> |
ClementBreteau | 1:f3f702086a30 | 18 | #endif |
ClementBreteau | 1:f3f702086a30 | 19 | #include "Base.h" |
ClementBreteau | 1:f3f702086a30 | 20 | #include "FileHandle.h" |
ClementBreteau | 1:f3f702086a30 | 21 | #include "DirHandle.h" |
ClementBreteau | 1:f3f702086a30 | 22 | |
ClementBreteau | 1:f3f702086a30 | 23 | namespace mbed { |
ClementBreteau | 1:f3f702086a30 | 24 | |
ClementBreteau | 1:f3f702086a30 | 25 | /* Class FileSystemLike |
ClementBreteau | 1:f3f702086a30 | 26 | * A filesystem-like object is one that can be used to open files |
ClementBreteau | 1:f3f702086a30 | 27 | * though it by fopen("/name/filename", mode) |
ClementBreteau | 1:f3f702086a30 | 28 | * |
ClementBreteau | 1:f3f702086a30 | 29 | * Implementations must define at least open (the default definitions |
ClementBreteau | 1:f3f702086a30 | 30 | * of the rest of the functions just return error values). |
ClementBreteau | 1:f3f702086a30 | 31 | */ |
ClementBreteau | 1:f3f702086a30 | 32 | class FileSystemLike : public Base { |
ClementBreteau | 1:f3f702086a30 | 33 | |
ClementBreteau | 1:f3f702086a30 | 34 | public: |
ClementBreteau | 1:f3f702086a30 | 35 | |
ClementBreteau | 1:f3f702086a30 | 36 | /* Constructor FileSystemLike |
ClementBreteau | 1:f3f702086a30 | 37 | * |
ClementBreteau | 1:f3f702086a30 | 38 | * Variables |
ClementBreteau | 1:f3f702086a30 | 39 | * name - The name to use for the filesystem. |
ClementBreteau | 1:f3f702086a30 | 40 | */ |
ClementBreteau | 1:f3f702086a30 | 41 | FileSystemLike(const char *name) : Base(name) {} |
ClementBreteau | 1:f3f702086a30 | 42 | |
ClementBreteau | 1:f3f702086a30 | 43 | /* Function open |
ClementBreteau | 1:f3f702086a30 | 44 | * |
ClementBreteau | 1:f3f702086a30 | 45 | * Variables |
ClementBreteau | 1:f3f702086a30 | 46 | * filename - The name of the file to open. |
ClementBreteau | 1:f3f702086a30 | 47 | * flags - One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with |
ClementBreteau | 1:f3f702086a30 | 48 | * zero or more of O_CREAT, O_TRUNC, or O_APPEND. |
ClementBreteau | 1:f3f702086a30 | 49 | * returns - A pointer to a FileHandle object representing the |
ClementBreteau | 1:f3f702086a30 | 50 | * file on success, or NULL on failure. |
ClementBreteau | 1:f3f702086a30 | 51 | */ |
ClementBreteau | 1:f3f702086a30 | 52 | virtual FileHandle *open(const char *filename, int flags) = 0; |
ClementBreteau | 1:f3f702086a30 | 53 | |
ClementBreteau | 1:f3f702086a30 | 54 | /* Function remove |
ClementBreteau | 1:f3f702086a30 | 55 | * Remove a file from the filesystem. |
ClementBreteau | 1:f3f702086a30 | 56 | * |
ClementBreteau | 1:f3f702086a30 | 57 | * Variables |
ClementBreteau | 1:f3f702086a30 | 58 | * filename - the name of the file to remove. |
ClementBreteau | 1:f3f702086a30 | 59 | * returns - 0 on success, -1 on failure. |
ClementBreteau | 1:f3f702086a30 | 60 | */ |
ClementBreteau | 1:f3f702086a30 | 61 | virtual int remove(const char *filename) { return -1; }; |
ClementBreteau | 1:f3f702086a30 | 62 | |
ClementBreteau | 1:f3f702086a30 | 63 | /* Function rename |
ClementBreteau | 1:f3f702086a30 | 64 | * Rename a file in the filesystem. |
ClementBreteau | 1:f3f702086a30 | 65 | * |
ClementBreteau | 1:f3f702086a30 | 66 | * Variables |
ClementBreteau | 1:f3f702086a30 | 67 | * oldname - the name of the file to rename. |
ClementBreteau | 1:f3f702086a30 | 68 | * newname - the name to rename it to. |
ClementBreteau | 1:f3f702086a30 | 69 | * returns - 0 on success, -1 on failure. |
ClementBreteau | 1:f3f702086a30 | 70 | */ |
ClementBreteau | 1:f3f702086a30 | 71 | virtual int rename(const char *oldname, const char *newname) { return -1; }; |
ClementBreteau | 1:f3f702086a30 | 72 | |
ClementBreteau | 1:f3f702086a30 | 73 | /* Function opendir |
ClementBreteau | 1:f3f702086a30 | 74 | * Opens a directory in the filesystem and returns a DirHandle |
ClementBreteau | 1:f3f702086a30 | 75 | * representing the directory stream. |
ClementBreteau | 1:f3f702086a30 | 76 | * |
ClementBreteau | 1:f3f702086a30 | 77 | * Variables |
ClementBreteau | 1:f3f702086a30 | 78 | * name - The name of the directory to open. |
ClementBreteau | 1:f3f702086a30 | 79 | * returns - A DirHandle representing the directory stream, or |
ClementBreteau | 1:f3f702086a30 | 80 | * NULL on failure. |
ClementBreteau | 1:f3f702086a30 | 81 | */ |
ClementBreteau | 1:f3f702086a30 | 82 | virtual DirHandle *opendir(const char *name) { return NULL; }; |
ClementBreteau | 1:f3f702086a30 | 83 | |
ClementBreteau | 1:f3f702086a30 | 84 | /* Function mkdir |
ClementBreteau | 1:f3f702086a30 | 85 | * Creates a directory in the filesystem. |
ClementBreteau | 1:f3f702086a30 | 86 | * |
ClementBreteau | 1:f3f702086a30 | 87 | * Variables |
ClementBreteau | 1:f3f702086a30 | 88 | * name - The name of the directory to create. |
ClementBreteau | 1:f3f702086a30 | 89 | * mode - The permissions to create the directory with. |
ClementBreteau | 1:f3f702086a30 | 90 | * returns - 0 on success, -1 on failure. |
ClementBreteau | 1:f3f702086a30 | 91 | */ |
ClementBreteau | 1:f3f702086a30 | 92 | virtual int mkdir(const char *name, mode_t mode) { return -1; } |
ClementBreteau | 1:f3f702086a30 | 93 | |
ClementBreteau | 1:f3f702086a30 | 94 | // TODO other filesystem functions (mkdir, rm, rn, ls etc) |
ClementBreteau | 1:f3f702086a30 | 95 | |
ClementBreteau | 1:f3f702086a30 | 96 | }; |
ClementBreteau | 1:f3f702086a30 | 97 | |
ClementBreteau | 1:f3f702086a30 | 98 | } // namespace mbed |
ClementBreteau | 1:f3f702086a30 | 99 | |
ClementBreteau | 1:f3f702086a30 | 100 | #endif |