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