Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of command_AX12_petit_robot by
mbed/FileSystemLike.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 - FileSystemLike |
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_FILESYSTEMLIKE_H |
SquirrelGod | 2:99b1cb0d9f5e | 6 | #define MBED_FILESYSTEMLIKE_H |
SquirrelGod | 2:99b1cb0d9f5e | 7 | |
SquirrelGod | 2:99b1cb0d9f5e | 8 | #ifdef __ARMCC_VERSION |
SquirrelGod | 2:99b1cb0d9f5e | 9 | # define O_RDONLY 0 |
SquirrelGod | 2:99b1cb0d9f5e | 10 | # define O_WRONLY 1 |
SquirrelGod | 2:99b1cb0d9f5e | 11 | # define O_RDWR 2 |
SquirrelGod | 2:99b1cb0d9f5e | 12 | # define O_CREAT 0x0200 |
SquirrelGod | 2:99b1cb0d9f5e | 13 | # define O_TRUNC 0x0400 |
SquirrelGod | 2:99b1cb0d9f5e | 14 | # define O_APPEND 0x0008 |
SquirrelGod | 2:99b1cb0d9f5e | 15 | typedef int mode_t; |
SquirrelGod | 2:99b1cb0d9f5e | 16 | #else |
SquirrelGod | 2:99b1cb0d9f5e | 17 | # include <sys/fcntl.h> |
SquirrelGod | 2:99b1cb0d9f5e | 18 | #endif |
SquirrelGod | 2:99b1cb0d9f5e | 19 | #include "Base.h" |
SquirrelGod | 2:99b1cb0d9f5e | 20 | #include "FileHandle.h" |
SquirrelGod | 2:99b1cb0d9f5e | 21 | #include "DirHandle.h" |
SquirrelGod | 2:99b1cb0d9f5e | 22 | |
SquirrelGod | 2:99b1cb0d9f5e | 23 | namespace mbed { |
SquirrelGod | 2:99b1cb0d9f5e | 24 | |
SquirrelGod | 2:99b1cb0d9f5e | 25 | /* Class FileSystemLike |
SquirrelGod | 2:99b1cb0d9f5e | 26 | * A filesystem-like object is one that can be used to open files |
SquirrelGod | 2:99b1cb0d9f5e | 27 | * though it by fopen("/name/filename", mode) |
SquirrelGod | 2:99b1cb0d9f5e | 28 | * |
SquirrelGod | 2:99b1cb0d9f5e | 29 | * Implementations must define at least open (the default definitions |
SquirrelGod | 2:99b1cb0d9f5e | 30 | * of the rest of the functions just return error values). |
SquirrelGod | 2:99b1cb0d9f5e | 31 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 32 | class FileSystemLike : public Base { |
SquirrelGod | 2:99b1cb0d9f5e | 33 | |
SquirrelGod | 2:99b1cb0d9f5e | 34 | public: |
SquirrelGod | 2:99b1cb0d9f5e | 35 | |
SquirrelGod | 2:99b1cb0d9f5e | 36 | /* Constructor FileSystemLike |
SquirrelGod | 2:99b1cb0d9f5e | 37 | * |
SquirrelGod | 2:99b1cb0d9f5e | 38 | * Variables |
SquirrelGod | 2:99b1cb0d9f5e | 39 | * name - The name to use for the filesystem. |
SquirrelGod | 2:99b1cb0d9f5e | 40 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 41 | FileSystemLike(const char *name) : Base(name) {} |
SquirrelGod | 2:99b1cb0d9f5e | 42 | |
SquirrelGod | 2:99b1cb0d9f5e | 43 | /* Function open |
SquirrelGod | 2:99b1cb0d9f5e | 44 | * |
SquirrelGod | 2:99b1cb0d9f5e | 45 | * Variables |
SquirrelGod | 2:99b1cb0d9f5e | 46 | * filename - The name of the file to open. |
SquirrelGod | 2:99b1cb0d9f5e | 47 | * flags - One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with |
SquirrelGod | 2:99b1cb0d9f5e | 48 | * zero or more of O_CREAT, O_TRUNC, or O_APPEND. |
SquirrelGod | 2:99b1cb0d9f5e | 49 | * returns - A pointer to a FileHandle object representing the |
SquirrelGod | 2:99b1cb0d9f5e | 50 | * file on success, or NULL on failure. |
SquirrelGod | 2:99b1cb0d9f5e | 51 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 52 | virtual FileHandle *open(const char *filename, int flags) = 0; |
SquirrelGod | 2:99b1cb0d9f5e | 53 | |
SquirrelGod | 2:99b1cb0d9f5e | 54 | /* Function remove |
SquirrelGod | 2:99b1cb0d9f5e | 55 | * Remove a file from the filesystem. |
SquirrelGod | 2:99b1cb0d9f5e | 56 | * |
SquirrelGod | 2:99b1cb0d9f5e | 57 | * Variables |
SquirrelGod | 2:99b1cb0d9f5e | 58 | * filename - the name of the file to remove. |
SquirrelGod | 2:99b1cb0d9f5e | 59 | * returns - 0 on success, -1 on failure. |
SquirrelGod | 2:99b1cb0d9f5e | 60 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 61 | virtual int remove(const char *filename) { return -1; }; |
SquirrelGod | 2:99b1cb0d9f5e | 62 | |
SquirrelGod | 2:99b1cb0d9f5e | 63 | /* Function rename |
SquirrelGod | 2:99b1cb0d9f5e | 64 | * Rename a file in the filesystem. |
SquirrelGod | 2:99b1cb0d9f5e | 65 | * |
SquirrelGod | 2:99b1cb0d9f5e | 66 | * Variables |
SquirrelGod | 2:99b1cb0d9f5e | 67 | * oldname - the name of the file to rename. |
SquirrelGod | 2:99b1cb0d9f5e | 68 | * newname - the name to rename it to. |
SquirrelGod | 2:99b1cb0d9f5e | 69 | * returns - 0 on success, -1 on failure. |
SquirrelGod | 2:99b1cb0d9f5e | 70 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 71 | virtual int rename(const char *oldname, const char *newname) { return -1; }; |
SquirrelGod | 2:99b1cb0d9f5e | 72 | |
SquirrelGod | 2:99b1cb0d9f5e | 73 | /* Function opendir |
SquirrelGod | 2:99b1cb0d9f5e | 74 | * Opens a directory in the filesystem and returns a DirHandle |
SquirrelGod | 2:99b1cb0d9f5e | 75 | * representing the directory stream. |
SquirrelGod | 2:99b1cb0d9f5e | 76 | * |
SquirrelGod | 2:99b1cb0d9f5e | 77 | * Variables |
SquirrelGod | 2:99b1cb0d9f5e | 78 | * name - The name of the directory to open. |
SquirrelGod | 2:99b1cb0d9f5e | 79 | * returns - A DirHandle representing the directory stream, or |
SquirrelGod | 2:99b1cb0d9f5e | 80 | * NULL on failure. |
SquirrelGod | 2:99b1cb0d9f5e | 81 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 82 | virtual DirHandle *opendir(const char *name) { return NULL; }; |
SquirrelGod | 2:99b1cb0d9f5e | 83 | |
SquirrelGod | 2:99b1cb0d9f5e | 84 | /* Function mkdir |
SquirrelGod | 2:99b1cb0d9f5e | 85 | * Creates a directory in the filesystem. |
SquirrelGod | 2:99b1cb0d9f5e | 86 | * |
SquirrelGod | 2:99b1cb0d9f5e | 87 | * Variables |
SquirrelGod | 2:99b1cb0d9f5e | 88 | * name - The name of the directory to create. |
SquirrelGod | 2:99b1cb0d9f5e | 89 | * mode - The permissions to create the directory with. |
SquirrelGod | 2:99b1cb0d9f5e | 90 | * returns - 0 on success, -1 on failure. |
SquirrelGod | 2:99b1cb0d9f5e | 91 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 92 | virtual int mkdir(const char *name, mode_t mode) { return -1; } |
SquirrelGod | 2:99b1cb0d9f5e | 93 | |
SquirrelGod | 2:99b1cb0d9f5e | 94 | // TODO other filesystem functions (mkdir, rm, rn, ls etc) |
SquirrelGod | 2:99b1cb0d9f5e | 95 | |
SquirrelGod | 2:99b1cb0d9f5e | 96 | }; |
SquirrelGod | 2:99b1cb0d9f5e | 97 | |
SquirrelGod | 2:99b1cb0d9f5e | 98 | } // namespace mbed |
SquirrelGod | 2:99b1cb0d9f5e | 99 | |
SquirrelGod | 2:99b1cb0d9f5e | 100 | #endif |