customized mbed library sources for nrf51822

Dependents:   Grove_Node Potentiometer BLE_Beacon I2C_Scanner

Committer:
yihui
Date:
Tue Nov 04 07:38:53 2014 +0000
Revision:
0:700cadd8b708
customized mbed-src library for nrf51822

Who changed what in which revision?

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