Created
June 30, 2018 10:19
-
-
Save felixklauke/2419e0adda6d1b1b42722cc521cee297 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Providing options for low level file access using an input and an output stream. | |
*/ | |
class FileSystemAccessor { | |
public: | |
/** | |
* Create a new file system accessor by passing the file we want to access under the hood. | |
* | |
* @param fileName The name / path of the file. | |
*/ | |
explicit FileSystemAccessor(std::string fileName); | |
/** | |
* The destructor that should take responsibility to close and delete the streams opened by the constructor. | |
*/ | |
virtual ~FileSystemAccessor(); | |
/** | |
* Read the given amount of bytes beginning from the given position into the given byte array. | |
* | |
* @param position The position to begin reading at. | |
* @param amount The amount of bytes to read. | |
* @param byteBuffer The byte array to read the bytes into. | |
*/ | |
void Read(int position, int amount, char *byteBuffer); | |
/** | |
* Write the given amount of bytes from the given byte array beginning at the given position. | |
* | |
* @param position The position to begin writing. | |
* @param amount The amount of bytes to read. | |
* @param byteBuffer The byte array of bytes to write. | |
*/ | |
void Write(int position, int amount, char *byteBuffer); | |
private: | |
/** | |
* The input stream used for reading from the file. | |
*/ | |
std::ifstream *inputStream; | |
/** | |
* The output stream used for writing into the file. | |
*/ | |
std::ofstream *outputStream; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment