mbed

Dependents:   DHTSensor_Test K64F_eCompass_OneNET_JW

Committer:
mbotkinl
Date:
Wed Feb 25 20:22:22 2015 +0000
Revision:
0:2cc6bb4d7fea
Working code to read Temperature and Humidity readings

Who changed what in which revision?

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