file
The File library allows reading and writing from/to external files using a C-like File IO API.
These functions are considered dangerous and require the user to manually permit them
Types
std::file::Handle
std::file::Handle
A handle representing a file that has been opened
std::file::Mode
std::file::Mode
The mode to open a file in. Read opens the file in read-only mode Write opens the file in read and write mode Create creates a new file if it doesn't exist and overwrites an existing file
Functions
std::file::open
std::file::open
Opens a file
path
: The path to the file to openmode
: File open modereturn
: Handle to the newly opened file
std::file::close
std::file::close
Closes a file handle that has been opened previously
handle
: The handle to close
std::file::read
std::file::read
Reads the content of a file into a string
handle
: The file handle to read fromsize
: Number of bytes to readreturn
: String containing the read data
std::file::write
std::file::write
Writes the content of a string into a file
handle
: The file handle to write todata
: String or Pattern to write to the file
std::file::seek
std::file::seek
Sets the current cursor position in the given file handle
handle
: The file handle to set the cursor position inoffset
: The offset to move the cursor to
std::file::size
std::file::size
Queries the size of a file
handle
: The handle of the file to get the size ofreturn
: The file's size
std::file::resize
std::file::resize
Resizes a file
handle
: The handle of the file to resize
std::file::flush
std::file::flush
Flushes changes made to a file to disk
handle
: The handle of the file to flush
std::file::remove
std::file::remove
Deletes a file from disk. This will also automatically close this file
handle
: The handle of the file to delete
std::file::create_directories
std::file::create_directories
Create all directories for the provided path
path
: The path for which all directories should be created
Last updated