#include <userver/fs/blocking/file_descriptor.hpp>
A file descriptor wrapper.
The file is closed in the destructor
- Note
- The operations on the file are blocking and not thread-safe
Definition at line 27 of file file_descriptor.hpp.
|
| | FileDescriptor () |
| | Default constructor.
|
|
| FileDescriptor (FileDescriptor &&other) noexcept |
|
FileDescriptor & | operator= (FileDescriptor &&other) noexcept |
| bool | IsOpen () const noexcept |
| | Checks if the file is open.
|
| void | Close () && |
| | Closes the file manually.
|
|
int | GetNative () const noexcept |
| | Returns the native file handle.
|
|
int | Release () && |
| | Passes the ownership of the file descriptor to the caller.
|
| void | Write (std::string_view contents) |
| | Writes data to the file.
|
| void | Write (std::span< const struct iovec > contents) |
| | Writes data to the file, has no IOV_MAX limits on contents.size().
|
| std::size_t | Read (char *buffer, std::size_t max_size) |
| | Reads data from the file at current offset.
|
| void | Seek (std::size_t offset_in_bytes) |
| | Sets the file read/write offset from the beginning of the file.
|
| void | FSync () |
| | Makes sure the written data is actually stored on disk.
|
| std::size_t | GetSize () const |
| | Fetches the file size.
|
◆ FileDescriptor()
| fs::blocking::FileDescriptor::FileDescriptor |
( |
| ) |
|
Default constructor.
- Note
- The file descriptor is not open
◆ Close()
| void fs::blocking::FileDescriptor::Close |
( |
| ) |
&& |
Closes the file manually.
- Exceptions
-
◆ FSync()
| void fs::blocking::FileDescriptor::FSync |
( |
| ) |
|
Makes sure the written data is actually stored on disk.
- Exceptions
-
◆ GetSize()
| std::size_t fs::blocking::FileDescriptor::GetSize |
( |
| ) |
const |
Fetches the file size.
- Exceptions
-
◆ IsOpen()
| bool fs::blocking::FileDescriptor::IsOpen |
( |
| ) |
const |
|
noexcept |
Checks if the file is open.
- Note
- Operations can only be performed on an open FileDescriptor.
◆ Open()
Open a file using ::open.
- Exceptions
-
◆ OpenDirectory()
Open a directory node.
- Note
- The only valid operation for such a FileDescriptor is FSync.
- Exceptions
-
◆ Read()
| std::size_t fs::blocking::FileDescriptor::Read |
( |
char * | buffer, |
|
|
std::size_t | max_size ) |
Reads data from the file at current offset.
- Returns
- The amount of bytes actually acquired, which can be equal to max_size, or less on end-of-file
- Exceptions
-
◆ Seek()
| void fs::blocking::FileDescriptor::Seek |
( |
std::size_t | offset_in_bytes | ) |
|
Sets the file read/write offset from the beginning of the file.
- Exceptions
-
◆ Write() [1/2]
| void fs::blocking::FileDescriptor::Write |
( |
std::span< const struct iovec > | contents | ) |
|
Writes data to the file, has no IOV_MAX limits on contents.size().
- Warning
- Unless FSync is called, there is no guarantee the data is stored on disk safely.
- Exceptions
-
◆ Write() [2/2]
| void fs::blocking::FileDescriptor::Write |
( |
std::string_view | contents | ) |
|
Writes data to the file.
- Warning
- Unless FSync is called, there is no guarantee the data is stored on disk safely.
- Exceptions
-
◆ TempFile
The documentation for this class was generated from the following file: