IOTIO

Dependencies:   Nucleo_BLE_API_IOTIO Nucleo_BLE_BlueNRG Nucleo_BLE_DemoApp Nucleo_Sensor_Shield mbed

Dependents:   Nucleo_BLE_Demo_IOTIO

Fork of Nucleo_BLE_Demo by Cortex Challenge Team

Committer:
16038618
Date:
Sat Oct 29 15:11:28 2016 +0000
Revision:
1:4bdfa7d7e8bf
IOTIO

Who changed what in which revision?

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