C++ Complementary Library
This class serves as a base class for classes that implement the platform-specific code for managing files. All platform-specific subclasses of basic_file are called simply file so that code that uses them stays the same across all platforms. You generally don't want to use this class directly in application code. Rather, you use the file class to read and write files on all supported platforms.
Constructs a basic_file object not associated with any file.
Constructs a basic_file object associated with the given file path and buffer capacity. No file is acquired from the operating system, only the path to the file and desired access mode are stored.
The file path to store in this basic file.
The access mode to store in this basic file.
The capacity of the I/O buffer to associate with this basic_file object.
Move-constructs a basic_file from an existing one.
The basic_file to move from.
Move-assigns a basic_file into this one.
The basic_file to move from.
Returns true if the file is open. Otherwise, returns false.
This functionality is platform-dependent and therefore this function must be overridden in a platform-specific subclass.
Returns the access mode associated with this basic file.
Returns true if the file is at its EOF (end-of-file) position. Otherwise, returns false.
Opens the file at the given path with the given access mode. The last argument tells what to do if the specified file doesn't already exists, that is, whether to create the file or fail to open it. Returns true if opening the file succeeds. Otherwise, returns false.
This functionality is platform-dependent and therefore this function must be overridden in a platform-specific subclass.
The path to the file to open.
The access mode to open the file in. This tells whether you want to just read, just write or both read and write. This cannot be changed later unless you close the file and reopen it.
The action to take if the specified file does not exist. This can be if_not_there::create, which causes the file to be created, or if_not_there::fail, which causes this function to simply return false without taking any action.
Flushes the I/O buffer and closes this basic file.
This functionality is platform-dependent and therefore this function must be overridden in a platform-specific subclass.
Reads byte_count bytes from this basic file and places them in the provided data array.
The array into which the read bytes will be placed.
The number of bytes to read from this basic file.
Writes byte_count bytes from the data array to this basic file.
The array of bytes that will be written to this basic file.
The number of bytes to write to this basic file.
Copyright © 2022-2025 Daniel T. McGinnis