DHT11

Committer:
jhon309
Date:
Thu Aug 13 00:21:57 2015 +0000
Revision:
0:c52df770855b
DHT11

Who changed what in which revision?

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