Rishka
RISC-V virtual runtime in C/C++ made for ESP32-WROVER
|
Class for handling file operations in Rishka applications. More...
#include <fs.h>
Public Member Functions | |
bool | is_file () |
Check if the object represents a file. More... | |
bool | is_dir () |
Check if the object represents a directory. More... | |
i32 | available () |
Get the number of bytes available for reading from the file. More... | |
i32 | peek () |
Peek at the next byte in the file without consuming it. More... | |
u64 | lastwrite () |
Get the timestamp of the last write operation on the file. More... | |
bool | bufsize (usize size) |
Set the buffer size for the file. More... | |
bool | seek (u32 pos) |
Set the current position within the file. More... | |
bool | seek_dir (u64 position) |
Set the current position within the directory. More... | |
usize | size () |
Get the size of the file. More... | |
usize | position () |
Get the current position within the file. More... | |
i32 | read () |
Read a byte from the file. More... | |
void | write (u8 data) |
Write a byte to the file. More... | |
void | write (string data) |
Write a string to the file. More... | |
string | path () |
Get the path of the file. More... | |
string | name () |
Get the name of the file. More... | |
File | next () |
Get the next file in the directory. More... | |
bool | is_ok () |
Checks if the file is in a valid state. More... | |
string | next_name () |
Get the name of the next file in the directory. More... | |
void | flush () |
Flush the file buffer. More... | |
void | close () |
Close the file. More... | |
void | rewind () |
Rewind the directory pointer to the beginning of the current working directory. More... | |
Static Public Member Functions | |
static File | open (string file, string mode) |
Open a file with the specified name and mode. More... | |
Protected Member Functions | |
File (i32 _handle) | |
Class for handling file operations in Rishka applications.
The File class provides methods for performing various file operations, such as opening, reading, writing, and closing files. It also includes functionalities for file navigation and querying file attributes.
|
protected |
Protected constructor for creating a file object
i32 File::available | ( | ) |
Get the number of bytes available for reading from the file.
This method returns the number of bytes available for reading from the file.
bool File::bufsize | ( | usize | size | ) |
Set the buffer size for the file.
This method sets the buffer size for the file. It determines the amount of data buffered in memory before being written to the file.
size | The buffer size to set, in bytes. |
void File::close | ( | ) |
Close the file.
This method closes the file, releasing any associated resources.
void File::flush | ( | ) |
Flush the file buffer.
This method flushes the file buffer, writing any buffered data to the file.
bool File::is_dir | ( | ) |
Check if the object represents a directory.
This method checks whether the File object represents a directory.
bool File::is_file | ( | ) |
Check if the object represents a file.
This method checks whether the File object represents a file.
bool File::is_ok | ( | ) |
Checks if the file is in a valid state.
This method checks if the file is in a valid state, i.e., if it has been successfully opened or created and is ready for reading or writing operations.
u64 File::lastwrite | ( | ) |
Get the timestamp of the last write operation on the file.
This method returns the timestamp of the last write operation performed on the file.
string File::name | ( | ) |
Get the name of the file.
This method returns the name of the file.
File File::next | ( | ) |
Get the next file in the directory.
This method returns the next file in the directory and advances the directory pointer.
string File::next_name | ( | ) |
Get the name of the next file in the directory.
This method returns the name of the next file in the directory without advancing the directory pointer.
Open a file with the specified name and mode.
This method opens a file with the given name and mode. The mode parameter specifies the access mode for the file (e.g., "r" for reading, "w" for writing).
file | The name of the file to open. |
mode | The mode in which to open the file (e.g., "r" for reading, "w" for writing). |
string File::path | ( | ) |
Get the path of the file.
This method returns the path of the file.
i32 File::peek | ( | ) |
Peek at the next byte in the file without consuming it.
This method peeks at the next byte in the file without consuming it.
usize File::position | ( | ) |
Get the current position within the file.
This method returns the current position within the file.
i32 File::read | ( | ) |
Read a byte from the file.
This method reads a byte from the file and advances the file pointer.
void File::rewind | ( | ) |
Rewind the directory pointer to the beginning of the current working directory.
This method rewinds the directory pointer to the beginning of the current working directory.
bool File::seek | ( | u32 | pos | ) |
Set the current position within the file.
This method sets the current position within the file to the specified position.
pos | The position to set. |
bool File::seek_dir | ( | u64 | position | ) |
Set the current position within the directory.
This method sets the current position within the directory to the specified position.
position | The position to set. |
usize File::size | ( | ) |
Get the size of the file.
This method returns the size of the file.
void File::write | ( | string | data | ) |
Write a string to the file.
This method writes a string to the file at the current position.
data | The string to write to the file. |
void File::write | ( | u8 | data | ) |
Write a byte to the file.
This method writes a byte to the file at the current position.
data | The byte to write to the file. |