init

Dependencies:   mbed

Committer:
Nathan Yonkee
Date:
Fri Mar 02 07:16:49 2018 -0700
Revision:
10:46a4cf51ee38
Parent:
9:d58e77ebd769
remove mbed-os

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nathan Yonkee 9:d58e77ebd769 1 /* mbed Microcontroller Library
Nathan Yonkee 9:d58e77ebd769 2 * Copyright (c) 2006-2013 ARM Limited
Nathan Yonkee 9:d58e77ebd769 3 *
Nathan Yonkee 9:d58e77ebd769 4 * Licensed under the Apache License, Version 2.0 (the "License");
Nathan Yonkee 9:d58e77ebd769 5 * you may not use this file except in compliance with the License.
Nathan Yonkee 9:d58e77ebd769 6 * You may obtain a copy of the License at
Nathan Yonkee 9:d58e77ebd769 7 *
Nathan Yonkee 9:d58e77ebd769 8 * http://www.apache.org/licenses/LICENSE-2.0
Nathan Yonkee 9:d58e77ebd769 9 *
Nathan Yonkee 9:d58e77ebd769 10 * Unless required by applicable law or agreed to in writing, software
Nathan Yonkee 9:d58e77ebd769 11 * distributed under the License is distributed on an "AS IS" BASIS,
Nathan Yonkee 9:d58e77ebd769 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Nathan Yonkee 9:d58e77ebd769 13 * See the License for the specific language governing permissions and
Nathan Yonkee 9:d58e77ebd769 14 * limitations under the License.
Nathan Yonkee 9:d58e77ebd769 15 */
Nathan Yonkee 9:d58e77ebd769 16 #ifndef MBED_FILESYSTEMHANDLE_H
Nathan Yonkee 9:d58e77ebd769 17 #define MBED_FILESYSTEMHANDLE_H
Nathan Yonkee 9:d58e77ebd769 18
Nathan Yonkee 9:d58e77ebd769 19 #include "platform/platform.h"
Nathan Yonkee 9:d58e77ebd769 20
Nathan Yonkee 9:d58e77ebd769 21 #include "platform/FileBase.h"
Nathan Yonkee 9:d58e77ebd769 22 #include "platform/FileHandle.h"
Nathan Yonkee 9:d58e77ebd769 23 #include "platform/DirHandle.h"
Nathan Yonkee 9:d58e77ebd769 24 #include "platform/NonCopyable.h"
Nathan Yonkee 9:d58e77ebd769 25
Nathan Yonkee 9:d58e77ebd769 26 namespace mbed {
Nathan Yonkee 9:d58e77ebd769 27 /** \addtogroup platform */
Nathan Yonkee 9:d58e77ebd769 28 /** @{*/
Nathan Yonkee 9:d58e77ebd769 29 /**
Nathan Yonkee 9:d58e77ebd769 30 * \defgroup platform_FileSystemHandle FileSystemHandle functions
Nathan Yonkee 9:d58e77ebd769 31 * @{
Nathan Yonkee 9:d58e77ebd769 32 */
Nathan Yonkee 9:d58e77ebd769 33
Nathan Yonkee 9:d58e77ebd769 34
Nathan Yonkee 9:d58e77ebd769 35 /** A filesystem-like object is one that can be used to open file-like
Nathan Yonkee 9:d58e77ebd769 36 * objects though it by fopen("/name/filename", mode)
Nathan Yonkee 9:d58e77ebd769 37 *
Nathan Yonkee 9:d58e77ebd769 38 * Implementations must define at least open (the default definitions
Nathan Yonkee 9:d58e77ebd769 39 * of the rest of the functions just return error values).
Nathan Yonkee 9:d58e77ebd769 40 *
Nathan Yonkee 9:d58e77ebd769 41 * @note Synchronization level: Set by subclass
Nathan Yonkee 9:d58e77ebd769 42 */
Nathan Yonkee 9:d58e77ebd769 43 class FileSystemHandle : private NonCopyable<FileSystemHandle> {
Nathan Yonkee 9:d58e77ebd769 44 public:
Nathan Yonkee 9:d58e77ebd769 45 /** FileSystemHandle lifetime
Nathan Yonkee 9:d58e77ebd769 46 */
Nathan Yonkee 9:d58e77ebd769 47 virtual ~FileSystemHandle() {}
Nathan Yonkee 9:d58e77ebd769 48
Nathan Yonkee 9:d58e77ebd769 49 /** Open a file on the filesystem
Nathan Yonkee 9:d58e77ebd769 50 *
Nathan Yonkee 9:d58e77ebd769 51 * @param file Destination for the handle to a newly created file
Nathan Yonkee 9:d58e77ebd769 52 * @param filename The name of the file to open
Nathan Yonkee 9:d58e77ebd769 53 * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR,
Nathan Yonkee 9:d58e77ebd769 54 * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
Nathan Yonkee 9:d58e77ebd769 55 * @return 0 on success, negative error code on failure
Nathan Yonkee 9:d58e77ebd769 56 */
Nathan Yonkee 9:d58e77ebd769 57 virtual int open(FileHandle **file, const char *filename, int flags) = 0;
Nathan Yonkee 9:d58e77ebd769 58
Nathan Yonkee 9:d58e77ebd769 59 /** Open a directory on the filesystem
Nathan Yonkee 9:d58e77ebd769 60 *
Nathan Yonkee 9:d58e77ebd769 61 * @param dir Destination for the handle to the directory
Nathan Yonkee 9:d58e77ebd769 62 * @param path Name of the directory to open
Nathan Yonkee 9:d58e77ebd769 63 * @return 0 on success, negative error code on failure
Nathan Yonkee 9:d58e77ebd769 64 */
Nathan Yonkee 9:d58e77ebd769 65 virtual int open(DirHandle **dir, const char *path);
Nathan Yonkee 9:d58e77ebd769 66
Nathan Yonkee 9:d58e77ebd769 67 /** Remove a file from the filesystem.
Nathan Yonkee 9:d58e77ebd769 68 *
Nathan Yonkee 9:d58e77ebd769 69 * @param path The name of the file to remove.
Nathan Yonkee 9:d58e77ebd769 70 * @return 0 on success, negative error code on failure
Nathan Yonkee 9:d58e77ebd769 71 */
Nathan Yonkee 9:d58e77ebd769 72 virtual int remove(const char *path);
Nathan Yonkee 9:d58e77ebd769 73
Nathan Yonkee 9:d58e77ebd769 74 /** Rename a file in the filesystem.
Nathan Yonkee 9:d58e77ebd769 75 *
Nathan Yonkee 9:d58e77ebd769 76 * @param path The name of the file to rename.
Nathan Yonkee 9:d58e77ebd769 77 * @param newpath The name to rename it to
Nathan Yonkee 9:d58e77ebd769 78 * @return 0 on success, negative error code on failure
Nathan Yonkee 9:d58e77ebd769 79 */
Nathan Yonkee 9:d58e77ebd769 80 virtual int rename(const char *path, const char *newpath);
Nathan Yonkee 9:d58e77ebd769 81
Nathan Yonkee 9:d58e77ebd769 82 /** Store information about the file in a stat structure
Nathan Yonkee 9:d58e77ebd769 83 *
Nathan Yonkee 9:d58e77ebd769 84 * @param path The name of the file to find information about
Nathan Yonkee 9:d58e77ebd769 85 * @param st The stat buffer to write to
Nathan Yonkee 9:d58e77ebd769 86 * @return 0 on success, negative error code on failure
Nathan Yonkee 9:d58e77ebd769 87 */
Nathan Yonkee 9:d58e77ebd769 88 virtual int stat(const char *path, struct stat *st);
Nathan Yonkee 9:d58e77ebd769 89
Nathan Yonkee 9:d58e77ebd769 90 /** Create a directory in the filesystem.
Nathan Yonkee 9:d58e77ebd769 91 *
Nathan Yonkee 9:d58e77ebd769 92 * @param path The name of the directory to create.
Nathan Yonkee 9:d58e77ebd769 93 * @param mode The permissions with which to create the directory
Nathan Yonkee 9:d58e77ebd769 94 * @return 0 on success, negative error code on failure
Nathan Yonkee 9:d58e77ebd769 95 */
Nathan Yonkee 9:d58e77ebd769 96 virtual int mkdir(const char *path, mode_t mode);
Nathan Yonkee 9:d58e77ebd769 97
Nathan Yonkee 9:d58e77ebd769 98 /** Store information about the mounted filesystem in a statvfs structure
Nathan Yonkee 9:d58e77ebd769 99 *
Nathan Yonkee 9:d58e77ebd769 100 * @param path The name of the file to find information about
Nathan Yonkee 9:d58e77ebd769 101 * @param buf The stat buffer to write to
Nathan Yonkee 9:d58e77ebd769 102 * @return 0 on success, negative error code on failure
Nathan Yonkee 9:d58e77ebd769 103 */
Nathan Yonkee 9:d58e77ebd769 104 virtual int statvfs(const char *path, struct statvfs *buf);
Nathan Yonkee 9:d58e77ebd769 105 };
Nathan Yonkee 9:d58e77ebd769 106 /**@}*/
Nathan Yonkee 9:d58e77ebd769 107
Nathan Yonkee 9:d58e77ebd769 108 /**@}*/
Nathan Yonkee 9:d58e77ebd769 109
Nathan Yonkee 9:d58e77ebd769 110 } // namespace mbed
Nathan Yonkee 9:d58e77ebd769 111
Nathan Yonkee 9:d58e77ebd769 112 #endif
Nathan Yonkee 9:d58e77ebd769 113
Nathan Yonkee 9:d58e77ebd769 114 /** @}*/