Home Alert System

Dependencies:   PWM_Tone_Library DHT

Committer:
aziz111
Date:
Fri Mar 08 17:15:02 2019 +0000
Revision:
5:569a4894abc1
Parent:
3:78f223d34f36
Final

Who changed what in which revision?

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