test

Dependents:   robotic_fish_7

Committer:
juansal12
Date:
Tue Jan 14 19:14:29 2020 +0000
Revision:
0:44931ff4a3ed
Sofi 7 code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
juansal12 0:44931ff4a3ed 1 /* mbed Microcontroller Library
juansal12 0:44931ff4a3ed 2 * Copyright (c) 2006-2013 ARM Limited
juansal12 0:44931ff4a3ed 3 *
juansal12 0:44931ff4a3ed 4 * Licensed under the Apache License, Version 2.0 (the "License");
juansal12 0:44931ff4a3ed 5 * you may not use this file except in compliance with the License.
juansal12 0:44931ff4a3ed 6 * You may obtain a copy of the License at
juansal12 0:44931ff4a3ed 7 *
juansal12 0:44931ff4a3ed 8 * http://www.apache.org/licenses/LICENSE-2.0
juansal12 0:44931ff4a3ed 9 *
juansal12 0:44931ff4a3ed 10 * Unless required by applicable law or agreed to in writing, software
juansal12 0:44931ff4a3ed 11 * distributed under the License is distributed on an "AS IS" BASIS,
juansal12 0:44931ff4a3ed 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
juansal12 0:44931ff4a3ed 13 * See the License for the specific language governing permissions and
juansal12 0:44931ff4a3ed 14 * limitations under the License.
juansal12 0:44931ff4a3ed 15 */
juansal12 0:44931ff4a3ed 16 #ifndef MBED_FILESYSTEMLIKE_H
juansal12 0:44931ff4a3ed 17 #define MBED_FILESYSTEMLIKE_H
juansal12 0:44931ff4a3ed 18
juansal12 0:44931ff4a3ed 19 #include "platform.h"
juansal12 0:44931ff4a3ed 20
juansal12 0:44931ff4a3ed 21 #include "FileBase.h"
juansal12 0:44931ff4a3ed 22 #include "FileHandle.h"
juansal12 0:44931ff4a3ed 23 #include "DirHandle.h"
juansal12 0:44931ff4a3ed 24
juansal12 0:44931ff4a3ed 25 namespace mbed {
juansal12 0:44931ff4a3ed 26
juansal12 0:44931ff4a3ed 27 /** A filesystem-like object is one that can be used to open files
juansal12 0:44931ff4a3ed 28 * though it by fopen("/name/filename", mode)
juansal12 0:44931ff4a3ed 29 *
juansal12 0:44931ff4a3ed 30 * Implementations must define at least open (the default definitions
juansal12 0:44931ff4a3ed 31 * of the rest of the functions just return error values).
juansal12 0:44931ff4a3ed 32 */
juansal12 0:44931ff4a3ed 33 class FileSystemLike : public FileBase {
juansal12 0:44931ff4a3ed 34
juansal12 0:44931ff4a3ed 35 public:
juansal12 0:44931ff4a3ed 36 /** FileSystemLike constructor
juansal12 0:44931ff4a3ed 37 *
juansal12 0:44931ff4a3ed 38 * @param name The name to use for the filesystem.
juansal12 0:44931ff4a3ed 39 */
juansal12 0:44931ff4a3ed 40 FileSystemLike(const char *name);
juansal12 0:44931ff4a3ed 41
juansal12 0:44931ff4a3ed 42 virtual ~FileSystemLike();
juansal12 0:44931ff4a3ed 43
juansal12 0:44931ff4a3ed 44 static DirHandle *opendir();
juansal12 0:44931ff4a3ed 45 friend class BaseDirHandle;
juansal12 0:44931ff4a3ed 46
juansal12 0:44931ff4a3ed 47 /** Opens a file from the filesystem
juansal12 0:44931ff4a3ed 48 *
juansal12 0:44931ff4a3ed 49 * @param filename The name of the file to open.
juansal12 0:44931ff4a3ed 50 * @param flags One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with
juansal12 0:44931ff4a3ed 51 * zero or more of O_CREAT, O_TRUNC, or O_APPEND.
juansal12 0:44931ff4a3ed 52 *
juansal12 0:44931ff4a3ed 53 * @returns
juansal12 0:44931ff4a3ed 54 * A pointer to a FileHandle object representing the
juansal12 0:44931ff4a3ed 55 * file on success, or NULL on failure.
juansal12 0:44931ff4a3ed 56 */
juansal12 0:44931ff4a3ed 57 virtual FileHandle *open(const char *filename, int flags) = 0;
juansal12 0:44931ff4a3ed 58
juansal12 0:44931ff4a3ed 59 /** Remove a file from the filesystem.
juansal12 0:44931ff4a3ed 60 *
juansal12 0:44931ff4a3ed 61 * @param filename the name of the file to remove.
juansal12 0:44931ff4a3ed 62 * @param returns 0 on success, -1 on failure.
juansal12 0:44931ff4a3ed 63 */
juansal12 0:44931ff4a3ed 64 virtual int remove(const char *filename) { return -1; };
juansal12 0:44931ff4a3ed 65
juansal12 0:44931ff4a3ed 66 /** Rename a file in the filesystem.
juansal12 0:44931ff4a3ed 67 *
juansal12 0:44931ff4a3ed 68 * @param oldname the name of the file to rename.
juansal12 0:44931ff4a3ed 69 * @param newname the name to rename it to.
juansal12 0:44931ff4a3ed 70 *
juansal12 0:44931ff4a3ed 71 * @returns
juansal12 0:44931ff4a3ed 72 * 0 on success,
juansal12 0:44931ff4a3ed 73 * -1 on failure.
juansal12 0:44931ff4a3ed 74 */
juansal12 0:44931ff4a3ed 75 virtual int rename(const char *oldname, const char *newname) { return -1; };
juansal12 0:44931ff4a3ed 76
juansal12 0:44931ff4a3ed 77 /** Opens a directory in the filesystem and returns a DirHandle
juansal12 0:44931ff4a3ed 78 * representing the directory stream.
juansal12 0:44931ff4a3ed 79 *
juansal12 0:44931ff4a3ed 80 * @param name The name of the directory to open.
juansal12 0:44931ff4a3ed 81 *
juansal12 0:44931ff4a3ed 82 * @returns
juansal12 0:44931ff4a3ed 83 * A DirHandle representing the directory stream, or
juansal12 0:44931ff4a3ed 84 * NULL on failure.
juansal12 0:44931ff4a3ed 85 */
juansal12 0:44931ff4a3ed 86 virtual DirHandle *opendir(const char *name) { return NULL; };
juansal12 0:44931ff4a3ed 87
juansal12 0:44931ff4a3ed 88 /** Creates a directory in the filesystem.
juansal12 0:44931ff4a3ed 89 *
juansal12 0:44931ff4a3ed 90 * @param name The name of the directory to create.
juansal12 0:44931ff4a3ed 91 * @param mode The permissions to create the directory with.
juansal12 0:44931ff4a3ed 92 *
juansal12 0:44931ff4a3ed 93 * @returns
juansal12 0:44931ff4a3ed 94 * 0 on success,
juansal12 0:44931ff4a3ed 95 * -1 on failure.
juansal12 0:44931ff4a3ed 96 */
juansal12 0:44931ff4a3ed 97 virtual int mkdir(const char *name, mode_t mode) { return -1; }
juansal12 0:44931ff4a3ed 98
juansal12 0:44931ff4a3ed 99 // TODO other filesystem functions (mkdir, rm, rn, ls etc)
juansal12 0:44931ff4a3ed 100 };
juansal12 0:44931ff4a3ed 101
juansal12 0:44931ff4a3ed 102 } // namespace mbed
juansal12 0:44931ff4a3ed 103
juansal12 0:44931ff4a3ed 104 #endif