I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

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