17#ifndef MBED_FILEHANDLE_H
18#define MBED_FILEHANDLE_H
20typedef 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;
123 return seek(0, SEEK_CUR);
167 return blocking ? 0 : -ENOTTY;
225 virtual short poll(
short events)
const
228 return POLLIN | POLLOUT;
239 return poll(POLLOUT) & POLLOUT;
250 return poll(POLLIN) & POLLIN;
Callback class based on template specialization.
virtual int enable_input(bool enabled)
Enable or disable input.
bool writable() const
Definition depends on the subclass implementing FileHandle.
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 bool is_blocking() const
Check current blocking or nonblocking mode for file operations.
bool readable() const
Definition depends on the subclass implementing FileHandle.
virtual void sigio(Callback< void()> func)
Register a callback on state change of the file.
virtual off_t tell()
Get the file position of the file.
virtual int truncate(off_t length)
Truncate or extend a file.
virtual int isatty()
Check if the file in an interactive terminal device.
virtual int sync()
Flush any buffers associated with the file.
virtual int enable_output(bool enabled)
Enable or disable output.
virtual int set_blocking(bool blocking)
Set blocking or nonblocking mode of the file operation like read/write.
virtual off_t size()
Get the size of the file.
virtual int close()=0
Close a file.
virtual short poll(short events) const
Check for poll event flags You can use or ignore the input parameter.
virtual void rewind()
Rewind the file position to the beginning of the file.
virtual ssize_t write(const void *buffer, size_t size)=0
Write the contents of a buffer to a file.
Prevents generation of copy constructor and copy assignment operator in derived classes.