PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Committer:
Pokitto
Date:
Wed Oct 11 20:35:27 2017 +0000
Revision:
5:ea7377f3d1af
Fixed PokittoLib. Includes a working custom mbed-src

Who changed what in which revision?

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