BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Committer:
gustavatmel
Date:
Tue May 01 15:55:34 2018 +0000
Revision:
2:798925c9e4a8
Parent:
1:9c5af431a1f1
bluetooth

Who changed what in which revision?

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