Describes predefine macros for mbed online compiler (armcc)

Committer:
MACRUM
Date:
Thu Mar 16 21:58:09 2017 +0900
Revision:
6:40e873bbc5f7
Add licence header info

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 6:40e873bbc5f7 1 /* mbed Microcontroller Library
MACRUM 6:40e873bbc5f7 2 * Copyright (c) 2006-2013 ARM Limited
MACRUM 6:40e873bbc5f7 3 *
MACRUM 6:40e873bbc5f7 4 * Licensed under the Apache License, Version 2.0 (the "License");
MACRUM 6:40e873bbc5f7 5 * you may not use this file except in compliance with the License.
MACRUM 6:40e873bbc5f7 6 * You may obtain a copy of the License at
MACRUM 6:40e873bbc5f7 7 *
MACRUM 6:40e873bbc5f7 8 * http://www.apache.org/licenses/LICENSE-2.0
MACRUM 6:40e873bbc5f7 9 *
MACRUM 6:40e873bbc5f7 10 * Unless required by applicable law or agreed to in writing, software
MACRUM 6:40e873bbc5f7 11 * distributed under the License is distributed on an "AS IS" BASIS,
MACRUM 6:40e873bbc5f7 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MACRUM 6:40e873bbc5f7 13 * See the License for the specific language governing permissions and
MACRUM 6:40e873bbc5f7 14 * limitations under the License.
MACRUM 6:40e873bbc5f7 15 */
MACRUM 6:40e873bbc5f7 16 #ifndef MBED_FILELIKE_H
MACRUM 6:40e873bbc5f7 17 #define MBED_FILELIKE_H
MACRUM 6:40e873bbc5f7 18
MACRUM 6:40e873bbc5f7 19 #include "platform/mbed_toolchain.h"
MACRUM 6:40e873bbc5f7 20 #include "drivers/FileBase.h"
MACRUM 6:40e873bbc5f7 21
MACRUM 6:40e873bbc5f7 22 namespace mbed {
MACRUM 6:40e873bbc5f7 23 /** \addtogroup drivers */
MACRUM 6:40e873bbc5f7 24 /** @{*/
MACRUM 6:40e873bbc5f7 25
MACRUM 6:40e873bbc5f7 26
MACRUM 6:40e873bbc5f7 27 /* Class FileLike
MACRUM 6:40e873bbc5f7 28 * A file-like object is one that can be opened with fopen by
MACRUM 6:40e873bbc5f7 29 * fopen("/name", mode).
MACRUM 6:40e873bbc5f7 30 *
MACRUM 6:40e873bbc5f7 31 * @Note Synchronization level: Set by subclass
MACRUM 6:40e873bbc5f7 32 */
MACRUM 6:40e873bbc5f7 33 class FileLike : public FileBase {
MACRUM 6:40e873bbc5f7 34 public:
MACRUM 6:40e873bbc5f7 35 /** Constructor FileLike
MACRUM 6:40e873bbc5f7 36 *
MACRUM 6:40e873bbc5f7 37 * @param name The name to use to open the file.
MACRUM 6:40e873bbc5f7 38 */
MACRUM 6:40e873bbc5f7 39 FileLike(const char *name = NULL) : FileBase(name, FilePathType) {}
MACRUM 6:40e873bbc5f7 40 virtual ~FileLike() {}
MACRUM 6:40e873bbc5f7 41
MACRUM 6:40e873bbc5f7 42 /** Read the contents of a file into a buffer
MACRUM 6:40e873bbc5f7 43 *
MACRUM 6:40e873bbc5f7 44 * @param buffer The buffer to read in to
MACRUM 6:40e873bbc5f7 45 * @param size The number of bytes to read
MACRUM 6:40e873bbc5f7 46 * @return The number of bytes read, 0 at end of file, negative error on failure
MACRUM 6:40e873bbc5f7 47 */
MACRUM 6:40e873bbc5f7 48 virtual ssize_t read(void *buffer, size_t len) = 0;
MACRUM 6:40e873bbc5f7 49
MACRUM 6:40e873bbc5f7 50 /** Write the contents of a buffer to a file
MACRUM 6:40e873bbc5f7 51 *
MACRUM 6:40e873bbc5f7 52 * @param buffer The buffer to write from
MACRUM 6:40e873bbc5f7 53 * @param size The number of bytes to write
MACRUM 6:40e873bbc5f7 54 * @return The number of bytes written, negative error on failure
MACRUM 6:40e873bbc5f7 55 */
MACRUM 6:40e873bbc5f7 56 virtual ssize_t write(const void *buffer, size_t len) = 0;
MACRUM 6:40e873bbc5f7 57
MACRUM 6:40e873bbc5f7 58 /** Close a file
MACRUM 6:40e873bbc5f7 59 *
MACRUM 6:40e873bbc5f7 60 * @return 0 on success, negative error code on failure
MACRUM 6:40e873bbc5f7 61 */
MACRUM 6:40e873bbc5f7 62 virtual int close() = 0;
MACRUM 6:40e873bbc5f7 63
MACRUM 6:40e873bbc5f7 64 /** Flush any buffers associated with the file
MACRUM 6:40e873bbc5f7 65 *
MACRUM 6:40e873bbc5f7 66 * @return 0 on success, negative error code on failure
MACRUM 6:40e873bbc5f7 67 */
MACRUM 6:40e873bbc5f7 68 virtual int sync() = 0;
MACRUM 6:40e873bbc5f7 69
MACRUM 6:40e873bbc5f7 70 /** Check if the file in an interactive terminal device
MACRUM 6:40e873bbc5f7 71 *
MACRUM 6:40e873bbc5f7 72 * @return True if the file is a terminal
MACRUM 6:40e873bbc5f7 73 */
MACRUM 6:40e873bbc5f7 74 virtual int isatty() = 0;
MACRUM 6:40e873bbc5f7 75
MACRUM 6:40e873bbc5f7 76 /** Move the file position to a given offset from from a given location
MACRUM 6:40e873bbc5f7 77 *
MACRUM 6:40e873bbc5f7 78 * @param offset The offset from whence to move to
MACRUM 6:40e873bbc5f7 79 * @param whence The start of where to seek
MACRUM 6:40e873bbc5f7 80 * SEEK_SET to start from beginning of file,
MACRUM 6:40e873bbc5f7 81 * SEEK_CUR to start from current position in file,
MACRUM 6:40e873bbc5f7 82 * SEEK_END to start from end of file
MACRUM 6:40e873bbc5f7 83 * @return The new offset of the file
MACRUM 6:40e873bbc5f7 84 */
MACRUM 6:40e873bbc5f7 85 virtual off_t seek(off_t offset, int whence = SEEK_SET) = 0;
MACRUM 6:40e873bbc5f7 86
MACRUM 6:40e873bbc5f7 87 /** Get the file position of the file
MACRUM 6:40e873bbc5f7 88 *
MACRUM 6:40e873bbc5f7 89 * @return The current offset in the file
MACRUM 6:40e873bbc5f7 90 */
MACRUM 6:40e873bbc5f7 91 virtual off_t tell() = 0;
MACRUM 6:40e873bbc5f7 92
MACRUM 6:40e873bbc5f7 93 /** Rewind the file position to the beginning of the file
MACRUM 6:40e873bbc5f7 94 *
MACRUM 6:40e873bbc5f7 95 * @note This is equivalent to file_seek(file, 0, FS_SEEK_SET)
MACRUM 6:40e873bbc5f7 96 */
MACRUM 6:40e873bbc5f7 97 virtual void rewind() = 0;
MACRUM 6:40e873bbc5f7 98
MACRUM 6:40e873bbc5f7 99 /** Get the size of the file
MACRUM 6:40e873bbc5f7 100 *
MACRUM 6:40e873bbc5f7 101 * @return Size of the file in bytes
MACRUM 6:40e873bbc5f7 102 */
MACRUM 6:40e873bbc5f7 103 virtual size_t size() = 0;
MACRUM 6:40e873bbc5f7 104
MACRUM 6:40e873bbc5f7 105 /** Move the file position to a given offset from a given location.
MACRUM 6:40e873bbc5f7 106 *
MACRUM 6:40e873bbc5f7 107 * @param offset The offset from whence to move to
MACRUM 6:40e873bbc5f7 108 * @param whence SEEK_SET for the start of the file, SEEK_CUR for the
MACRUM 6:40e873bbc5f7 109 * current file position, or SEEK_END for the end of the file.
MACRUM 6:40e873bbc5f7 110 *
MACRUM 6:40e873bbc5f7 111 * @returns
MACRUM 6:40e873bbc5f7 112 * new file position on success,
MACRUM 6:40e873bbc5f7 113 * -1 on failure or unsupported
MACRUM 6:40e873bbc5f7 114 */
MACRUM 6:40e873bbc5f7 115 MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by FileLike::seek")
MACRUM 6:40e873bbc5f7 116 virtual off_t lseek(off_t offset, int whence) { return seek(offset, whence); }
MACRUM 6:40e873bbc5f7 117
MACRUM 6:40e873bbc5f7 118 /** Flush any buffers associated with the FileHandle, ensuring it
MACRUM 6:40e873bbc5f7 119 * is up to date on disk
MACRUM 6:40e873bbc5f7 120 *
MACRUM 6:40e873bbc5f7 121 * @returns
MACRUM 6:40e873bbc5f7 122 * 0 on success or un-needed,
MACRUM 6:40e873bbc5f7 123 * -1 on error
MACRUM 6:40e873bbc5f7 124 */
MACRUM 6:40e873bbc5f7 125 MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by FileLike::sync")
MACRUM 6:40e873bbc5f7 126 virtual int fsync() { return sync(); }
MACRUM 6:40e873bbc5f7 127
MACRUM 6:40e873bbc5f7 128 /** Find the length of the file
MACRUM 6:40e873bbc5f7 129 *
MACRUM 6:40e873bbc5f7 130 * @returns
MACRUM 6:40e873bbc5f7 131 * Length of the file
MACRUM 6:40e873bbc5f7 132 */
MACRUM 6:40e873bbc5f7 133 MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by FileLike::size")
MACRUM 6:40e873bbc5f7 134 virtual off_t flen() { return size(); }
MACRUM 6:40e873bbc5f7 135
MACRUM 6:40e873bbc5f7 136 protected:
MACRUM 6:40e873bbc5f7 137 /** Acquire exclusive access to this object.
MACRUM 6:40e873bbc5f7 138 */
MACRUM 6:40e873bbc5f7 139 virtual void lock() {
MACRUM 6:40e873bbc5f7 140 // Stub
MACRUM 6:40e873bbc5f7 141 }
MACRUM 6:40e873bbc5f7 142
MACRUM 6:40e873bbc5f7 143 /** Release exclusive access to this object.
MACRUM 6:40e873bbc5f7 144 */
MACRUM 6:40e873bbc5f7 145 virtual void unlock() {
MACRUM 6:40e873bbc5f7 146 // Stub
MACRUM 6:40e873bbc5f7 147 }
MACRUM 6:40e873bbc5f7 148 };
MACRUM 6:40e873bbc5f7 149
MACRUM 6:40e873bbc5f7 150
MACRUM 6:40e873bbc5f7 151 /** @}*/
MACRUM 6:40e873bbc5f7 152 } // namespace mbed
MACRUM 6:40e873bbc5f7 153
MACRUM 6:40e873bbc5f7 154 #endif