Structure for handling streams of data.
More...
#include <file.h>
operations, when errored, will return a corresponding error. Use file::get_error() to check if an error is present and return a corresponding string. Use file::clear_error() to clear the errored state. Some operations, specifically file::rename() and file::copy().
|
|
| file () |
| | default constructor, initializes an empty stream
|
| |
|
| ~file () |
| | default destructor, cleans up an open stream
|
| |
| | file (file &&file) noexcept |
| | move constructor
|
| |
| const path & | get_path () const |
| |
| uint8_t | mode () const |
| |
| bool | is_open () const |
| |
| bool | open (const cstring &path, uint8_t mode) |
| | open a file
|
| |
| bool | open (const string &path, uint8_t mode) |
| | open a file
|
| |
| bool | open (const path &path, uint8_t mode) |
| | open a file
|
| |
| bool | close () |
| | close a stream
|
| |
| bool | commit () |
| | commit the streams buffer to the file
|
| |
| bool | erase () |
| | closes the stream and erases the file
|
| |
| bool | rename (const cstring &path) |
| | rebinds the stream, copying contents to path, and erasing the old file
|
| |
| bool | rename (const string &path) |
| | rebinds the stream, copying contents to path, and erasing the old file
|
| |
| bool | rename (const path &path) |
| | rebinds the stream, copying contents to path, and erasing the old file
|
| |
| file | copy (const cstring &path) |
| | copies the contents of this file to path.
|
| |
| file | copy (const string &path) |
| | copies the contents of this file to path.
|
| |
| file | copy (const path &path) |
| | copies the contents of this file to path.
|
| |
|
|
static constexpr size_t | npos = -1 |
| | value of an invalid position
|
| |
◆ file()
| fennec::file::file |
( |
file && |
file | ) |
|
|
noexcept |
- Parameters
-
| file | the stream to take ownership of |
◆ is_valid()
| static constexpr bool fennec::file::is_valid |
( |
uint8_t |
mode | ) |
|
|
inlinestaticconstexpr |
- Parameters
-
- Returns
- true if the combination of flags is valid, false otherwise
◆ cout()
| file & fennec::file::cout |
( |
| ) |
|
|
static |
◆ cin()
| file & fennec::file::cin |
( |
| ) |
|
|
static |
◆ cerr()
| file & fennec::file::cerr |
( |
| ) |
|
|
static |
◆ get_path()
| const path & fennec::file::get_path |
( |
| ) |
const |
|
inline |
- Returns
- the path the stream
◆ mode()
| uint8_t fennec::file::mode |
( |
| ) |
const |
|
inline |
- Returns
- the mode of the stream
◆ is_open()
| bool fennec::file::is_open |
( |
| ) |
const |
|
inline |
- Returns
- true if there is a valid, open stream.
◆ open() [1/3]
- Parameters
-
| path | the path to the file |
| mode | the mode flags to open the file with |
- Returns
- false on success, true on error
◆ open() [2/3]
- Parameters
-
| path | the path to the file |
| mode | the mode flags to open the file with |
- Returns
- false on success, true on error
◆ open() [3/3]
| bool fennec::file::open |
( |
const path & |
path, |
|
|
uint8_t |
mode |
|
) |
| |
- Parameters
-
| path | the path to the file |
| mode | the mode flags to open the file with |
- Returns
- false on success, true on error
◆ close()
| bool fennec::file::close |
( |
| ) |
|
- Returns
- false on success, true on error
◆ commit()
| bool fennec::file::commit |
( |
| ) |
|
- Returns
- false on success, true on error
◆ erase()
| bool fennec::file::erase |
( |
| ) |
|
- Returns
- false on success, true on error
◆ rename() [1/3]
| bool fennec::file::rename |
( |
const cstring & |
path | ) |
|
- Parameters
-
- Returns
- false on success, true on error
attempts to open a write-only stream at path, attempts to reopen this file as read-only, copies the contents of this file to the new stream, reopen the new stream with the flags of this file and binds to it, closes the old file.
◆ rename() [2/3]
| bool fennec::file::rename |
( |
const string & |
path | ) |
|
- Parameters
-
- Returns
- false on success, true on error
attempts to open a write-only stream at path, attempts to reopen this file as read-only, copies the contents of this file to the new stream, reopen the new stream with the flags of this file and binds to it, closes the old file.
◆ rename() [3/3]
| bool fennec::file::rename |
( |
const path & |
path | ) |
|
- Parameters
-
- Returns
- false on success, true on error
attempts to open a write-only stream at path, attempts to reopen this file as read-only, copies the contents of this file to the new stream, reopen the new stream with the flags of this file and binds to it, closes the old file.
◆ copy() [1/3]
- Parameters
-
- Returns
- a file at the new path with the copied contents
◆ copy() [2/3]
- Parameters
-
- Returns
- a file at the new path with the copied contents
◆ copy() [3/3]
| file fennec::file::copy |
( |
const path & |
path | ) |
|
- Parameters
-
- Returns
- a file at the new path with the copied contents
The documentation for this class was generated from the following files:
- include/fennec/filesystem/file.h
- source/filesystem/file.cpp