Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Tue Jul 04 06:23:13 2017 +0000
Revision:
170:54ff26da7eb6
Parent:
166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 166:3a9487d57a5c 1 /* mbed Microcontroller Library
thedo 166:3a9487d57a5c 2 * Copyright (c) 2015 ARM Limited
thedo 166:3a9487d57a5c 3 *
thedo 166:3a9487d57a5c 4 * Licensed under the Apache License, Version 2.0 (the "License");
thedo 166:3a9487d57a5c 5 * you may not use this file except in compliance with the License.
thedo 166:3a9487d57a5c 6 * You may obtain a copy of the License at
thedo 166:3a9487d57a5c 7 *
thedo 166:3a9487d57a5c 8 * http://www.apache.org/licenses/LICENSE-2.0
thedo 166:3a9487d57a5c 9 *
thedo 166:3a9487d57a5c 10 * Unless required by applicable law or agreed to in writing, software
thedo 166:3a9487d57a5c 11 * distributed under the License is distributed on an "AS IS" BASIS,
thedo 166:3a9487d57a5c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
thedo 166:3a9487d57a5c 13 * See the License for the specific language governing permissions and
thedo 166:3a9487d57a5c 14 * limitations under the License.
thedo 166:3a9487d57a5c 15 */
thedo 166:3a9487d57a5c 16
thedo 166:3a9487d57a5c 17 #ifndef FILE_H
thedo 166:3a9487d57a5c 18 #define FILE_H
thedo 166:3a9487d57a5c 19
thedo 166:3a9487d57a5c 20 #include "filesystem/FileSystem.h"
thedo 166:3a9487d57a5c 21 #include "platform/FileHandle.h"
thedo 166:3a9487d57a5c 22
thedo 166:3a9487d57a5c 23 namespace mbed {
thedo 166:3a9487d57a5c 24 /** \addtogroup filesystem */
thedo 166:3a9487d57a5c 25 /** @{*/
thedo 166:3a9487d57a5c 26
thedo 166:3a9487d57a5c 27
thedo 166:3a9487d57a5c 28 /** File class
thedo 166:3a9487d57a5c 29 */
thedo 166:3a9487d57a5c 30 class File : public FileHandle {
thedo 166:3a9487d57a5c 31 public:
thedo 166:3a9487d57a5c 32 /** Create an uninitialized file
thedo 166:3a9487d57a5c 33 *
thedo 166:3a9487d57a5c 34 * Must call open to initialize the file on a file system
thedo 166:3a9487d57a5c 35 */
thedo 166:3a9487d57a5c 36 File();
thedo 166:3a9487d57a5c 37
thedo 166:3a9487d57a5c 38 /** Create a file on a filesystem
thedo 166:3a9487d57a5c 39 *
thedo 166:3a9487d57a5c 40 * Creates and opens a file on a filesystem
thedo 166:3a9487d57a5c 41 *
thedo 166:3a9487d57a5c 42 * @param fs Filesystem as target for the file
thedo 166:3a9487d57a5c 43 * @param path The name of the file to open
thedo 166:3a9487d57a5c 44 * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR,
thedo 166:3a9487d57a5c 45 * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
thedo 166:3a9487d57a5c 46 */
thedo 166:3a9487d57a5c 47 File(FileSystem *fs, const char *path, int flags = O_RDONLY);
thedo 166:3a9487d57a5c 48
thedo 166:3a9487d57a5c 49 /** Destroy a file
thedo 166:3a9487d57a5c 50 *
thedo 166:3a9487d57a5c 51 * Closes file if the file is still open
thedo 166:3a9487d57a5c 52 */
thedo 166:3a9487d57a5c 53 virtual ~File();
thedo 166:3a9487d57a5c 54
thedo 166:3a9487d57a5c 55 /** Open a file on the filesystem
thedo 166:3a9487d57a5c 56 *
thedo 166:3a9487d57a5c 57 * @param fs Filesystem as target for the file
thedo 166:3a9487d57a5c 58 * @param path The name of the file to open
thedo 166:3a9487d57a5c 59 * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR,
thedo 166:3a9487d57a5c 60 * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
thedo 166:3a9487d57a5c 61 * @return 0 on success, negative error code on failure
thedo 166:3a9487d57a5c 62 */
thedo 166:3a9487d57a5c 63 virtual int open(FileSystem *fs, const char *path, int flags=O_RDONLY);
thedo 166:3a9487d57a5c 64
thedo 166:3a9487d57a5c 65 /** Close a file
thedo 166:3a9487d57a5c 66 *
thedo 166:3a9487d57a5c 67 * @return 0 on success, negative error code on failure
thedo 166:3a9487d57a5c 68 */
thedo 166:3a9487d57a5c 69 virtual int close();
thedo 166:3a9487d57a5c 70
thedo 166:3a9487d57a5c 71 /** Read the contents of a file into a buffer
thedo 166:3a9487d57a5c 72 *
thedo 166:3a9487d57a5c 73 * @param buffer The buffer to read in to
thedo 166:3a9487d57a5c 74 * @param size The number of bytes to read
thedo 166:3a9487d57a5c 75 * @return The number of bytes read, 0 at end of file, negative error on failure
thedo 166:3a9487d57a5c 76 */
thedo 166:3a9487d57a5c 77
thedo 166:3a9487d57a5c 78 virtual ssize_t read(void *buffer, size_t size);
thedo 166:3a9487d57a5c 79
thedo 166:3a9487d57a5c 80 /** Write the contents of a buffer to a file
thedo 166:3a9487d57a5c 81 *
thedo 166:3a9487d57a5c 82 * @param buffer The buffer to write from
thedo 166:3a9487d57a5c 83 * @param size The number of bytes to write
thedo 166:3a9487d57a5c 84 * @return The number of bytes written, negative error on failure
thedo 166:3a9487d57a5c 85 */
thedo 166:3a9487d57a5c 86 virtual ssize_t write(const void *buffer, size_t size);
thedo 166:3a9487d57a5c 87
thedo 166:3a9487d57a5c 88 /** Flush any buffers associated with the file
thedo 166:3a9487d57a5c 89 *
thedo 166:3a9487d57a5c 90 * @return 0 on success, negative error code on failure
thedo 166:3a9487d57a5c 91 */
thedo 166:3a9487d57a5c 92 virtual int sync();
thedo 166:3a9487d57a5c 93
thedo 166:3a9487d57a5c 94 /** Check if the file in an interactive terminal device
thedo 166:3a9487d57a5c 95 *
thedo 166:3a9487d57a5c 96 * @return True if the file is a terminal
thedo 166:3a9487d57a5c 97 */
thedo 166:3a9487d57a5c 98 virtual int isatty();
thedo 166:3a9487d57a5c 99
thedo 166:3a9487d57a5c 100 /** Move the file position to a given offset from from a given location
thedo 166:3a9487d57a5c 101 *
thedo 166:3a9487d57a5c 102 * @param offset The offset from whence to move to
thedo 166:3a9487d57a5c 103 * @param whence The start of where to seek
thedo 166:3a9487d57a5c 104 * SEEK_SET to start from beginning of file,
thedo 166:3a9487d57a5c 105 * SEEK_CUR to start from current position in file,
thedo 166:3a9487d57a5c 106 * SEEK_END to start from end of file
thedo 166:3a9487d57a5c 107 * @return The new offset of the file
thedo 166:3a9487d57a5c 108 */
thedo 166:3a9487d57a5c 109 virtual off_t seek(off_t offset, int whence = SEEK_SET);
thedo 166:3a9487d57a5c 110
thedo 166:3a9487d57a5c 111 /** Get the file position of the file
thedo 166:3a9487d57a5c 112 *
thedo 166:3a9487d57a5c 113 * @return The current offset in the file
thedo 166:3a9487d57a5c 114 */
thedo 166:3a9487d57a5c 115 virtual off_t tell();
thedo 166:3a9487d57a5c 116
thedo 166:3a9487d57a5c 117 /** Rewind the file position to the beginning of the file
thedo 166:3a9487d57a5c 118 *
thedo 166:3a9487d57a5c 119 * @note This is equivalent to file_seek(file, 0, FS_SEEK_SET)
thedo 166:3a9487d57a5c 120 */
thedo 166:3a9487d57a5c 121 virtual void rewind();
thedo 166:3a9487d57a5c 122
thedo 166:3a9487d57a5c 123 /** Get the size of the file
thedo 166:3a9487d57a5c 124 *
thedo 166:3a9487d57a5c 125 * @return Size of the file in bytes
thedo 166:3a9487d57a5c 126 */
thedo 166:3a9487d57a5c 127 virtual off_t size();
thedo 166:3a9487d57a5c 128
thedo 166:3a9487d57a5c 129 private:
thedo 166:3a9487d57a5c 130 FileSystem *_fs;
thedo 166:3a9487d57a5c 131 fs_file_t _file;
thedo 166:3a9487d57a5c 132 };
thedo 166:3a9487d57a5c 133
thedo 166:3a9487d57a5c 134
thedo 166:3a9487d57a5c 135 /** @}*/
thedo 166:3a9487d57a5c 136 } // namespace mbed
thedo 166:3a9487d57a5c 137
thedo 166:3a9487d57a5c 138 #endif
thedo 166:3a9487d57a5c 139