Wraps the UNIX file handle in RAII fashion. Constructing opens the file and destructing closes it, so using this as an auto variable saves you from manually tracking all file closures. Errors also cause exceptions rather than returning an error status.
Public Member Functions | |
channel (const char *path, int flags=O_RDONLY, mode_t mode=S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) | |
Open the file at path with open flags and permission mode. | |
channel () | |
Constructs without any referenced file. | |
void | chdir () |
Changes the working directory to this file. | |
void | chown (uid_t owner, gid_t group) |
Changes the file ownership to owner and group. | |
void | flags (int flags) |
Sets the flags. | |
int | flags () |
Gets the flags. | |
std::size_t | read (void *buffer, std::size_t nbytes) |
Reads bytes into buffer. | |
off_t | seek (off_t offset=0, int whence=SEEK_SET) |
Positions the file at offset bytes. | |
void | sync () |
Synchronizes with the file system. | |
void | truncate (off_t length) |
Truncates the file to length bytes. | |
std::size_t | write (const void *buffer, std::size_t nbytes) |
Writes nbytes bytes from buffer. | |
~channel () | |
Closes the file. |