test

Dependents:   robotic_fish_6

Committer:
juansal12
Date:
Fri Dec 03 23:00:34 2021 +0000
Revision:
0:c792b17d9f78
uploaded sofi code ;

Who changed what in which revision?

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