|
Gateware Libraries
6.3.A
Beta Build
|
Cross platform FileIO/Directory handling. More...
#include <GFile.h>
Public Member Functions | |
| virtual GReturn | OpenBinaryRead (const char *const _file)=0 |
| Opens a file for binary read. More... | |
| virtual GReturn | OpenBinaryWrite (const char *const _file)=0 |
| Opens a file for binary write with truncation. More... | |
| virtual GReturn | AppendBinaryWrite (const char *const _file)=0 |
| Opens a file for binary write with append. More... | |
| virtual GReturn | OpenTextRead (const char *const _file)=0 |
| Opens a file for text read. More... | |
| virtual GReturn | OpenTextWrite (const char *const _file)=0 |
| Opens a file for text write with truncation. More... | |
| virtual GReturn | AppendTextWrite (const char *const _file)=0 |
| Opens a file for text write with append. More... | |
| virtual GReturn | Write (const char *const _inData, unsigned int _numBytes)=0 |
| Writes binary data to the currently opened file. More... | |
| virtual GReturn | Read (char *_outData, unsigned int _numBytes)=0 |
| Reads binary from the currently opened file. More... | |
| virtual GReturn | WriteLine (const char *const _inData)=0 |
| Writes text to the currently opened file. More... | |
| virtual GReturn | ReadLine (char *_outData, unsigned int _outDataSize, char _delimiter)=0 |
| Reads text to the currently opened file. More... | |
| virtual GReturn | CloseFile ()=0 |
| Flushes and closes the current file. More... | |
| virtual GReturn | FlushFile ()=0 |
| Flushes the current file. More... | |
| virtual GReturn | SetCurrentWorkingDirectory (const char *const _dir)=0 |
| Changes the current working directory. More... | |
| virtual GReturn | GetCurrentWorkingDirectory (char *_outDir, unsigned int _dirSize)=0 |
| Retrieves the absolute path of the current working directory. More... | |
| virtual GReturn | GetDirectorySize (unsigned int &_outSize)=0 |
| Gets the number of files in the current working directory. More... | |
| virtual GReturn | GetFilesFromDirectory (char *_outFiles[], unsigned int _numFiles, unsigned int _fileNameSize)=0 |
| Gets the names of all files in the current working directory. More... | |
| virtual GReturn | GetFileSize (const char *const _file, unsigned int &_outSize)=0 |
| Gets the size of the specified file in bytes. More... | |
Public Member Functions inherited from GW::CORE::GInterface | |
| virtual GReturn | GetCount (unsigned int &_outCount)=0 |
| Return the total number of active references to this object. More... | |
| virtual GReturn | IncrementCount ()=0 |
| Increase the total number of active references to this object. More... | |
| virtual GReturn | DecrementCount ()=0 |
| Decrease the total number of active references to this object. More... | |
| virtual GReturn | RequestInterface (const GUUIID &_interfaceID, void **_outputInterface)=0 |
| Requests an interface that may or may not be supported by this object. More... | |
Cross platform FileIO/Directory handling.
Handles file input/output operations, as well as directory information and file information. GFile inherits directly from GMultiThreaded, therefore its implementation must be thread safe.
|
pure virtual |
Opens a file for binary write with append.
The file name passed into the function should be passed like it is a relative path. The function will look in the current working directory for the file. If the file is not found in the current working directory, the file will be created in the current working directory. File can now be written to with Write().
| [in] | _file | The file name of the file to open. |
| SUCCESS | Succesfully opened the file. |
| FAILURE | A file is already open or the file could not be found/created. |
| INVALID_ARGUMENT | A nullptr was passed in. |
|
pure virtual |
Opens a file for text write with append.
The file name passed into the function should be passed like it is a relative path. The function will look in the current working directory for the file. If the file is not found in the current working directory, the file will be created in the current working directory. File can now be written to with Write().
| [in] | _file | The file name of the file to open. |
| SUCCESS | Succesfully opened the file. |
| FAILURE | A file is already open or the file could not be found/created. |
| INVALID_ARGUMENT | A nullptr was passed in. |
|
pure virtual |
Flushes and closes the current file.
| SUCCESS | File successfully flushed and closed. |
| FAILURE | A file is not currently open. |
|
pure virtual |
Flushes the current file.
| SUCCESS | File successfully flushed. |
| FAILURE | A file is not currently open. |
|
pure virtual |
Retrieves the absolute path of the current working directory.
This is the directory we will look into for any file Open commands. This is by Windows standard guaranteed to be 255 or less.
| [out] | _outDir | An absolute path to the directory to set as the current working directory. |
| [in] | _dirSize | The size of _outDir. |
| SUCCESS | Successfully obtained the working directory. |
| FAILURE | The current working directory is invalid or _outDir was not big enough. _outDir will be null. |
| INVALID_ARGUMENT | A nullptr was passed in or the size is 0. |
|
pure virtual |
Gets the number of files in the current working directory.
| [out] | _outSize | The number of files in the directory. |
| SUCCESS | Successfully counted the files in the directory. |
| FAILURE | Either currently working directory is invalid or count failed. _outSize will be -1. |
|
pure virtual |
Gets the names of all files in the current working directory.
This function will retrieve just the file names and extensions. Any Open function using these names will assume the files are in the current working directory. Any change of the current working directory will make the names generated by this function invalid until called again.
| [out] | _outFiles | Stores the names of the files retrieved. |
| [in] | _numFiles | The number of files. |
| [in] | _fileNameSize | The size of the file names. |
| SUCCESS | Successfully retrieved the file names. |
| FAILURE | Either current working directory is invalid or obtaining file names failed. |
|
pure virtual |
Gets the size of the specified file in bytes.
The filename passed into this function should be passed as a relative path. This function will assume the file passed in is in the current working directory and will look for it there.
| [in] | _file | The file to get the size of. |
| [out] | _outSize | will store the size of the file. |
| SUCCESS | Successfully retrieved the file size. |
| FILE_NOT_FOUND | Could not locate the file. Check that the current working directory is valid. |
|
pure virtual |
Opens a file for binary read.
The file name passed into the function should be passed like it is a relative path. The function will look in the current working directory for the file. If the file is not found in the current working directory, the function will fail.
| [in] | _file | The file name of the file to open. |
| SUCCESS | Succesfully opened the file. |
| FILE_NOT_FOUND | File could not be found. |
| FAILURE | A file is already opened. |
| INVALID_ARGUMENT | A null pointer was passed in. |
|
pure virtual |
Opens a file for binary write with truncation.
The file name passed into the function should be passed like it is a relative path. The function will look in the current working directory for the file. If the file is not found in the current working directory, the file will be created in the current working directory. File can now be read from with Read().
| [in] | _file | The file name of the file to open. |
| SUCCESS | Succesfully opened the file. |
| FAILURE | A file is already open or file could not be found/created. |
| INVALID_ARGUMENT | A nullptr was passed in. |
|
pure virtual |
Opens a file for text read.
The file name passed into the function should be passed like it is a relative path. The function will look in the current working directory for the file. If the file is not found in the current working directory, the function will fail. File can now be written to with Write().
| [in] | _file | The file name of the file to open. |
| SUCCESS | Succesfully opened the file. |
| FILE_NOT_FOUND | File could not be found. |
| FAILURE | A file is already open. |
| INVALID_ARGUMENT | A nullptr was passed in. |
|
pure virtual |
Opens a file for text write with truncation.
The file name passed into the function should be passed like it is a relative path. The function will look in the current working directory for the file. If the file is not found in the current working directory, the file will be created in the current working directory. File can now be read from with Read().
| [in] | _file | The file name of the file to open. |
| SUCCESS | Succesfully opened the file. |
| FAILURE | A file is already open or the file could not be found/created. |
| INVALID_ARGUMENT | A nullptr was passed in. |
|
pure virtual |
Reads binary from the currently opened file.
Reads binary data and stores it into a char* until the byte limit is reached.
| [out] | _outData | The variable to store the read in bytes. |
| [in] | _numBytes | The number of bytes to read in from the file. |
| SUCCESS | Successful read. |
| FAILURE | Either file is not open or read failed. _outData will be null. |
| INVALID_ARGUMENT | A byte size of 0 was passed in. |
|
pure virtual |
Reads text to the currently opened file.
Reads text from the current file until either the size is reached or delimiter is reached.
| [out] | _outData | Null terminated string to write out. |
| [in] | _outDataSize | The size of _outData. |
| [in] | _delimiter | The delimiter to stop reading at. |
| SUCCESS | Successful read. |
| FAILURE | Either file is not open or read failed. |
| INVALID_ARGUMENT | Either a nullptr was passed in or the size request is 0. |
|
pure virtual |
Changes the current working directory.
This sets the directory we will look into with any of the Open functions or other directory functions. Paths that are not relative to the directory the program was ran from should be passed in as absolute paths.
| [in] | _dir | An absolute path to the directory to set as the current working directory. |
| SUCCESS | Succesfully set the current working directory. |
| FILE_NOT_FOUND | The directory could not be found. |
| FAILURE | Failed to open directory (Could be because it was not found). |
| INVALID_ARGUMENT | A nullptr was passed in. |
|
pure virtual |
Writes binary data to the currently opened file.
Will append or truncate file based on what mode the currently opened file was opened with.
| [in] | _inData | The data to write out to file. |
| [in] | _numBytes | The number of bytes to write out to the file. |
| SUCCESS | Succesfully wrote out the data. |
| FAILURE | Either a file is not open or the write failed. |
| INVALID_ARGUMENT | Either a nullptr was passed in or a size of 0 bytes was passed in. |
|
pure virtual |
Writes text to the currently opened file.
Will append or truncate file based on what mode the currently opened file was opened with.
| [in] | _inData | Null terminated string to write out. |
| SUCCESS | Successful write. |
| FAILURE | Either file is not open or read failed. |
| INVALID_ARGUMENT | A nullptr was passed in. |