#include <ugdk/filesystem/file.h>
virtual ugdk::filesystem::File::~File |
( |
| ) |
|
|
inlinevirtual |
ugdk::filesystem::File::File |
( |
| ) |
|
|
inlineprotected |
bool ugdk::filesystem::File::CanSeek |
( |
| ) |
|
- Returns
- Whether this file can successfully seek.
virtual bool ugdk::filesystem::File::Close |
( |
| ) |
|
|
pure virtual |
Flushes data and closes the file. Any operations on a closed file are undefined behaviour.
- Returns
- True on success, false on error.
int ugdk::filesystem::File::fgetc |
( |
| ) |
|
Reads the next character from the given input stream.
- Returns
- The obtained character on success or EOF on failure.
char* ugdk::filesystem::File::fgets |
( |
char * |
str, |
|
|
int |
count |
|
) |
| |
Reads at most count - 1 characters from the given file stream and stores them in str. The produced character string is always null-terminated. Parsing stops if end-of-file occurs or a newline character is found, in which case str will contain that newline character.
- Parameters
-
str | string to read the characters to |
count | the length of str |
- Returns
- str on success, NULL on failure.
virtual std::string ugdk::filesystem::File::filename |
( |
| ) |
const |
|
pure virtual |
The name of the file this object represents. There's no guarantee a request to open a file with the name returned will succeed.
- Returns
- A string containing a filepath, or a special string for files that don't exist in the file system.
std::string ugdk::filesystem::File::GetContents |
( |
| ) |
|
Get the whole file in a string. Can only be used in files supporting seek.
- Returns
- A string containing the contents of the file.
template<class T >
std::size_t ugdk::filesystem::File::Read |
( |
T * |
ptr, |
|
|
std::size_t |
maxnum = 1 |
|
) |
| |
|
inline |
Reads up to maxnum objects of type T and save at ptr.
- Parameters
-
ptr | The buffer where the objects will be saved. |
maxnum | The maximum number of objects to be read. |
- Returns
- The number of objects read, or 0 if end of file or error.
- See also
- ReadRaw
virtual std::size_t ugdk::filesystem::File::ReadRaw |
( |
void * |
ptr, |
|
|
std::size_t |
size, |
|
|
std::size_t |
maxnum |
|
) |
| |
|
pure virtual |
Reads up to maxnum blocks of the given size and save at ptr.
- Parameters
-
ptr | The buffer where the data will be saved. |
size | The size of each memory block to be read, in bytes. |
maxnum | The maximum number of blocks to be read. |
- Returns
- The number of blocks read, or 0 if end of file or error.
Seek to an offset of whence.
- Parameters
-
offset | The offset to the given location. |
whence | One of the SeekPositions. |
- Returns
- The final offset in the file stream, relative to the start. -1 if an error occured.
virtual int64 ugdk::filesystem::File::size |
( |
| ) |
const |
|
pure virtual |
- Returns
- The size of this file, or -1 if unknown.
int64 ugdk::filesystem::File::Tell |
( |
| ) |
|
- Returns
- The current offset in the file stream, relative to the start.
- See also
- Seek
template<class T >
std::size_t ugdk::filesystem::File::Write |
( |
const T * |
ptr, |
|
|
std::size_t |
num = 1 |
|
) |
| |
|
inline |
Writes num objects of type T from ptr.
- Parameters
-
ptr | The buffer from where the objects are read. |
num | The number of objects to write. |
- Returns
- The number of objects written, or 0 if end of file or error.
- See also
- WriteRaw
virtual std::size_t ugdk::filesystem::File::WriteRaw |
( |
const void * |
ptr, |
|
|
std::size_t |
size, |
|
|
std::size_t |
num |
|
) |
| |
|
pure virtual |
Writes num blocks of the given size from ptr.
- Parameters
-
ptr | The buffer from where the data is read. |
size | The size of each memory block to be written, in bytes. |
maxnum | The maximum number of blocks to be written. |
- Returns
- The number of blocks written, or 0 if end of file or error.
The documentation for this class was generated from the following file:
- modules/ugdk-core/include/ugdk/filesystem/file.h