mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Committer:
emilmont
Date:
Mon Feb 18 09:41:56 2013 +0000
Revision:
9:663789d7729f
Parent:
8:c14af7958ef5
Update mbed-KL25Z to latest build

Who changed what in which revision?

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