Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of gr-peach-opencv-project-sd-card by
FileHandle Class Reference
[Platform]
Class FileHandle. More...
#include <FileHandle.h>
Inherited by ManagedFile, File, FileLike, LocalFileHandle, and UARTSerial.
Public Member Functions | |
virtual ssize_t | read (void *buffer, size_t size)=0 |
Read the contents of a file into a buffer. | |
virtual ssize_t | write (const void *buffer, size_t size)=0 |
Write the contents of a buffer to a file. | |
virtual off_t | seek (off_t offset, int whence=SEEK_SET)=0 |
Move the file position to a given offset from from a given location. | |
virtual int | close ()=0 |
Close a file. | |
virtual int | sync () |
Flush any buffers associated with the file. | |
virtual int | isatty () |
Check if the file in an interactive terminal device. | |
virtual off_t | tell () |
Get the file position of the file. | |
virtual void | rewind () |
Rewind the file position to the beginning of the file. | |
virtual off_t | size () |
Get the size of the file. | |
MBED_DEPRECATED_SINCE ("mbed-os-5.4","Replaced by FileHandle::seek") virtual off_t lseek(off_t offset | |
Move the file position to a given offset from a given location. |
Detailed Description
Class FileHandle.
An abstract interface that represents operations on a file-like object. The core functions are read, write, and seek, but only a subset of these operations can be provided.
- Note:
- to create a file,
- See also:
- File
- Note:
- Synchronization level: Set by subclass
Definition at line 40 of file FileHandle.h.
Member Function Documentation
virtual int close | ( | ) | [pure virtual] |
virtual int isatty | ( | ) | [virtual] |
Check if the file in an interactive terminal device.
- Returns:
- True if the file is a terminal
- False if the file is not a terminal
- Negative error code on failure
Reimplemented in File, and Stream.
Definition at line 98 of file FileHandle.h.
MBED_DEPRECATED_SINCE | ( | "mbed-os-5.4" | , |
"Replaced by FileHandle::seek" | |||
) |
Move the file position to a given offset from a given location.
- Parameters:
-
offset The offset from whence to move to whence SEEK_SET for the start of the file, SEEK_CUR for the current file position, or SEEK_END for the end of the file.
- Returns:
- new file position on success, -1 on failure or unsupported
virtual ssize_t read | ( | void * | buffer, |
size_t | size | ||
) | [pure virtual] |
Read the contents of a file into a buffer.
Devices acting as FileHandles should follow POSIX semantics:
* if no data is available, and non-blocking set return -EAGAIN * if no data is available, and blocking set, wait until data is available * If any data is available, call returns immediately
- Parameters:
-
buffer The buffer to read in to size The number of bytes to read
- Returns:
- The number of bytes read, 0 at end of file, negative error on failure
virtual void rewind | ( | ) | [virtual] |
Rewind the file position to the beginning of the file.
- Note:
- This is equivalent to seek(0, SEEK_SET)
Reimplemented in File, and Stream.
Definition at line 118 of file FileHandle.h.
virtual off_t seek | ( | off_t | offset, |
int | whence = SEEK_SET |
||
) | [pure virtual] |
Move the file position to a given offset from from a given location.
- Parameters:
-
offset The offset from whence to move to whence The start of where to seek SEEK_SET to start from beginning of file, SEEK_CUR to start from current position in file, SEEK_END to start from end of file
- Returns:
- The new offset of the file, negative error code on failure
off_t size | ( | ) | [virtual] |
Get the size of the file.
- Returns:
- Size of the file in bytes
Reimplemented in File, and Stream.
Definition at line 22 of file FileHandle.cpp.
virtual int sync | ( | ) | [virtual] |
Flush any buffers associated with the file.
- Returns:
- 0 on success, negative error code on failure
Reimplemented in File, and Stream.
Definition at line 87 of file FileHandle.h.
virtual off_t tell | ( | ) | [virtual] |
Get the file position of the file.
- Note:
- This is equivalent to seek(0, SEEK_CUR)
- Returns:
- The current offset in the file, negative error code on failure
Reimplemented in File, and Stream.
Definition at line 109 of file FileHandle.h.
Generated on Tue Jul 12 2022 14:48:04 by
