#include <userver/fs/blocking/c_file.hpp>
A std::FILE*
wrapper.
The file is closed in the destructor
- Note
- The operations on the file are blocking and not thread-safe
Definition at line 24 of file c_file.hpp.
|
| CFile () |
| Creates an empty file handle.
|
|
| CFile (CFile &&) noexcept |
|
CFile & | operator= (CFile &&) noexcept |
|
| CFile (const std::string &path, OpenMode flags, boost::filesystem::perms perms=boost::filesystem::perms::owner_read|boost::filesystem::perms::owner_write) |
| Opens the file.
|
|
| CFile (std::FILE *file) noexcept |
| Adopt the std::FILE* directly.
|
|
bool | IsOpen () const |
| Checks if the file is open.
|
|
std::FILE * | GetNative () & |
| Returns the underlying file handle.
|
|
std::FILE * | Release () && |
| Passes the ownership of the file to the caller.
|
|
void | Close () && |
| Closes the file manually.
|
|
std::size_t | Read (char *buffer, std::size_t max_size) |
| Reads data from the file.
|
|
void | Write (std::string_view data) |
| Writes data to the file.
|
|
void | Flush () |
| Synchronizes the written data with the file on disk.
|
|
void | FlushLight () |
| Synchronizes the written data with the file on disk without fsync.
|
|
std::uint64_t | GetPosition () const |
| Fetches the current position in the file.
|
|
std::uint64_t | GetSize () const |
| Fetches the file size.
|
|
◆ CFile()
fs::blocking::CFile::CFile |
( |
const std::string & | path, |
|
|
OpenMode | flags, |
|
|
boost::filesystem::perms | perms = boost::filesystem::perms::owner_read|boost::filesystem::perms::owner_write ) |
Opens the file.
- Exceptions
-
◆ Close()
void fs::blocking::CFile::Close |
( |
| ) |
&& |
Closes the file manually.
- Exceptions
-
◆ Flush()
void fs::blocking::CFile::Flush |
( |
| ) |
|
Synchronizes the written data with the file on disk.
- Exceptions
-
◆ FlushLight()
void fs::blocking::CFile::FlushLight |
( |
| ) |
|
Synchronizes the written data with the file on disk without fsync.
- Exceptions
-
◆ GetPosition()
std::uint64_t fs::blocking::CFile::GetPosition |
( |
| ) |
const |
Fetches the current position in the file.
- Exceptions
-
◆ GetSize()
std::uint64_t fs::blocking::CFile::GetSize |
( |
| ) |
const |
Fetches the file size.
- Exceptions
-
◆ Read()
std::size_t fs::blocking::CFile::Read |
( |
char * | buffer, |
|
|
std::size_t | max_size ) |
Reads data from the file.
- Returns
- The amount of bytes actually acquired, which can be equal to
max_size
, or less on end-of-file
- Exceptions
-
◆ Write()
void fs::blocking::CFile::Write |
( |
std::string_view | data | ) |
|
Writes data to the file.
- Warning
- Unless
Flush
is called, there is no guarantee the file on disk is actually updated
- Exceptions
-
The documentation for this class was generated from the following file: