17 #ifndef MBED_FILEHANDLE_H 18 #define MBED_FILEHANDLE_H 20 typedef int FILEHANDLE;
23 #include "platform/Callback.h" 24 #include "platform/mbed_poll.h" 25 #include "platform/platform.h" 26 #include "platform/NonCopyable.h" 62 virtual ssize_t
read(
void *buffer,
size_t size) = 0;
76 virtual ssize_t
write(
const void *buffer,
size_t size) = 0;
87 virtual off_t
seek(off_t offset,
int whence = SEEK_SET) = 0;
93 virtual int close() = 0;
123 return seek(0, SEEK_CUR);
139 virtual off_t
size();
169 virtual off_t
lseek(off_t offset,
int whence)
171 return seek(offset, whence);
211 return blocking ? 0 : -ENOTTY;
272 return POLLIN | POLLOUT;
283 return poll(POLLOUT) & POLLOUT;
294 return poll(POLLIN) & POLLIN;
virtual off_t size()
Get the size of the file.
virtual void sigio(Callback< void()> func)
Register a callback on state change of the file.
bool readable() const
Definition depends on the subclass implementing FileHandle.
virtual int set_blocking(bool blocking)
Set blocking or nonblocking mode of the file operation like read/write.
virtual ssize_t write(const void *buffer, size_t size)=0
Write the contents of a buffer to a file.
virtual int enable_output(bool enabled)
Enable or disable output.
virtual int close()=0
Close a file.
virtual int fsync()
Flush any buffers associated with the FileHandle, ensuring it is up to date on disk.
virtual int isatty()
Check if the file in an interactive terminal device.
virtual off_t lseek(off_t offset, int whence)
Move the file position to a given offset from a given location.
Prevents generation of copy constructor and copy assignment operator in derived classes.
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 ssize_t read(void *buffer, size_t size)=0
Read the contents of a file into a buffer.
virtual int sync()
Flush any buffers associated with the file.
virtual off_t flen()
Find the length of the file.
virtual short poll(short events) const
Check for poll event flags You can use or ignore the input parameter.
virtual int truncate(off_t length)
Truncate or extend a file.
virtual int enable_input(bool enabled)
Enable or disable input.
virtual void rewind()
Rewind the file position to the beginning of the file.
virtual off_t tell()
Get the file position of the file.
bool writable() const
Definition depends on the subclass implementing FileHandle.
Callback class based on template specialization.
virtual bool is_blocking() const
Check current blocking or nonblocking mode for file operations.