Fork of mbed for KL05Z based smart sensor which has no crystal on the board, so MCG FEI mode is required.

Dependents:   smart-sensor-KL05Z-debug

Fork of mbed-src by Ermanno Brusadin

Committer:
ebrus
Date:
Wed Jul 27 18:35:32 2016 +0000
Revision:
0:0a673c671a56
4

Who changed what in which revision?

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