test

Dependencies:   mbed Watchdog

Dependents:   STM32-MC_node

Committer:
ommpy
Date:
Mon Jul 06 17:18:59 2020 +0530
Revision:
0:d383e2dee0f7
first commit

Who changed what in which revision?

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