#include <FileLoader.hpp>
|
| static bool | fileExists (const std::string &path) |
| | Check if a file exists. More...
|
| |
| static void | listFiles (const std::string &path, std::vector< std::string > &list) |
| | Enumerate all files within a directory. More...
|
| |
| static void | listFilesRecursive (const std::string &path, std::vector< std::string > &list) |
| | Enumerate all files within a directory recursively. More...
|
| |
| static bool | deleteFile (const Directory dir, const std::string &file) |
| | Delete a file. More...
|
| |
| static bool | readTextfile (const std::string &path, std::string &file) |
| | Read a text file. More...
|
| |
| static bool | readBinaryfile (const std::string &path, std::vector< uint8 > &buffer) |
| | Read a binary file. More...
|
| |
| static bool | writeTextfile (const Directory dir, const std::string &path, const std::string &text, const bool append=false) |
| | Write a text file. More...
|
| |
| static bool | writeBinaryfile (const Directory dir, const std::string &path, const void *data, const std::size_t bytes, const bool append=false) |
| | Write a binary file. More...
|
| |
| static bool | makeDirectory (const Directory dir, const std::string &path) |
| | Create a directory. More...
|
| |
| static const std::string & | getDirectory (const Directory dir) |
| | Get a base directory as string. More...
|
| |
| static char | getDirectorySeparator () |
| | Get the OS-specific directory separator. More...
|
| |
| static void | enableErrorChecks (const bool enable) |
| | Enable/disable file system error checks. More...
|
| |
| static bool | errorChecksEnabled () |
| | Check if file system error checks are enabled. More...
|
| |
Definition at line 55 of file FileLoader.hpp.
Base directory for writing files
| Enumerator |
|---|
| Executable |
Executable directory.
|
| Resource |
Resource folder. On Android this is the memory card directory.
|
| User |
User folder. On Android this is the same directory as Executable.
|
Definition at line 65 of file FileLoader.hpp.
| jop::FileLoader::FileLoader |
( |
| ) |
|
Default constructor.
Doesn't initialize any file handles.
| jop::FileLoader::FileLoader |
( |
const std::string & |
path | ) |
|
|
explicit |
Overloaded constructor.
This will open the file for reading if found
- Parameters
-
- See also
- isValid()
| jop::FileLoader::FileLoader |
( |
const Directory |
dir, |
|
|
const std::string & |
path, |
|
|
const bool |
append |
|
) |
| |
Overloaded constructor.
This will open the file for writing if found.
- Parameters
-
| dir | Base write directory |
| path | Path to file to open |
| append | Append to the file. False to clear the file before writing |
- See also
- isValid()
| jop::FileLoader::FileLoader |
( |
FileLoader && |
other | ) |
|
| jop::FileLoader::~FileLoader |
( |
| ) |
|
Destructor.
Will close the file handle if open.
| void jop::FileLoader::close |
( |
| ) |
|
Close the file handle.
If no file handle is open, this will have no effect. When writing, calling this means saving the file.
| static bool jop::FileLoader::deleteFile |
( |
const Directory |
dir, |
|
|
const std::string & |
file |
|
) |
| |
|
static |
Delete a file.
- Parameters
-
| dir | The base write directory |
| file | Path to the file |
- Returns
- True if file was successfully deleted
| static void jop::FileLoader::enableErrorChecks |
( |
const bool |
enable | ) |
|
|
static |
Enable/disable file system error checks.
- Parameters
-
| static bool jop::FileLoader::errorChecksEnabled |
( |
| ) |
|
|
static |
Check if file system error checks are enabled.
- Returns
- True if enabled
| static bool jop::FileLoader::fileExists |
( |
const std::string & |
path | ) |
|
|
static |
Check if a file exists.
- Parameters
-
| path | Path to the file to check |
- Returns
- True if the file exists
| void jop::FileLoader::flush |
( |
| ) |
|
Flush the file stream.
This function only has an effect when writing to a file. Once called all buffered file output will be flushed and written to disk.
If no file handle is open, this will have no effect.
| static const std::string& jop::FileLoader::getDirectory |
( |
const Directory |
dir | ) |
|
|
static |
Get a base directory as string.
- Parameters
-
- Returns
- Internal reference to the directory string
| static char jop::FileLoader::getDirectorySeparator |
( |
| ) |
|
|
static |
Get the OS-specific directory separator.
- Returns
- The directory separator
| int64 jop::FileLoader::getSize |
( |
| ) |
const |
Get the size of the opened file.
- Returns
- Size of the file
| bool jop::FileLoader::isValid |
( |
| ) |
const |
Check if a file handle is open.
- Returns
- True if a valid file handle exists
| static void jop::FileLoader::listFiles |
( |
const std::string & |
path, |
|
|
std::vector< std::string > & |
list |
|
) |
| |
|
static |
Enumerate all files within a directory.
- Parameters
-
| path | Path to a directory |
| list | Reference to a list to fill with the file paths found |
- See also
- listFilesRecursive
| static void jop::FileLoader::listFilesRecursive |
( |
const std::string & |
path, |
|
|
std::vector< std::string > & |
list |
|
) |
| |
|
static |
Enumerate all files within a directory recursively.
- Warning
- On Android, files cannot be enumerated recursively from the .apk.
- Parameters
-
| path | Path to a directory |
| list | Reference to a list to fill with the file paths found |
- See also
- listFiles
| static bool jop::FileLoader::makeDirectory |
( |
const Directory |
dir, |
|
|
const std::string & |
path |
|
) |
| |
|
static |
Create a directory.
If the directory already exists, this has no effect.
- Parameters
-
| dir | The base write directory |
| path | The directory to create |
- Returns
- True if successful
| bool jop::FileLoader::open |
( |
const std::string & |
path | ) |
|
Open a file for reading.
- Parameters
-
- Returns
- True if opened successfully
| bool jop::FileLoader::open |
( |
const Directory |
dir, |
|
|
const std::string & |
path, |
|
|
const bool |
append |
|
) |
| |
Open a file for writing.
This will open the file for writing if found.
- Parameters
-
| dir | Base write directory |
| path | Path to file to open |
| append | Append to the file. False to clear the file before writing |
- See also
- isValid()
- Returns
- True if opened successfully
| jop::FileLoader::operator bool |
( |
| ) |
const |
Check if a file handle is open.
- Returns
- True if a valid file handle exists
Move assignment operator.
- Returns
- Reference to self
| int64 jop::FileLoader::read |
( |
void * |
data, |
|
|
const uint64 |
size |
|
) |
| |
Read data.
- Parameters
-
| data | Pointer to a pre-allocated data buffer |
| size | Amount of data to read |
- Returns
- Amount of data read in bytes
- See also
- getSize()
| static bool jop::FileLoader::readBinaryfile |
( |
const std::string & |
path, |
|
|
std::vector< uint8 > & |
buffer |
|
) |
| |
|
static |
Read a binary file.
- Parameters
-
| path | Path to the file to read |
| buffer | Reference to a buffer to fill with the data |
- Returns
- True if successful
| static bool jop::FileLoader::readTextfile |
( |
const std::string & |
path, |
|
|
std::string & |
file |
|
) |
| |
|
static |
Read a text file.
- Parameters
-
| path | Path to the file to read |
| file | Reference to a string to fill with the data |
- Returns
- True if successful
| bool jop::FileLoader::seek |
( |
const uint64 |
position | ) |
|
Move the file cursor to the given position.
- Parameters
-
| position | The cursor position to set in bytes |
- Returns
- True if successful
| int64 jop::FileLoader::tell |
( |
| ) |
const |
Get the current position of the cursor.
- Returns
- Current position of the file read/write cursor. -1 in case of failure
| int64 jop::FileLoader::write |
( |
const void * |
data, |
|
|
const uint64 |
size |
|
) |
| |
Write data.
- Parameters
-
| data | Data to write |
| size | Amount of data to write in bytes |
- Returns
- Amount of data written in bytes
| static bool jop::FileLoader::writeBinaryfile |
( |
const Directory |
dir, |
|
|
const std::string & |
path, |
|
|
const void * |
data, |
|
|
const std::size_t |
bytes, |
|
|
const bool |
append = false |
|
) |
| |
|
static |
Write a binary file.
- Parameters
-
| dir | The base write directory |
| path | The file path |
| data | The binary data to write |
| bytes | amount of bytes to write |
| append | Append to file? |
- Returns
- True if successful
| static bool jop::FileLoader::writeTextfile |
( |
const Directory |
dir, |
|
|
const std::string & |
path, |
|
|
const std::string & |
text, |
|
|
const bool |
append = false |
|
) |
| |
|
static |
Write a text file.
- Parameters
-
| dir | The base write directory |
| path | The file path |
| text | The text to write |
| append | Append to file? |
- Returns
- True if successful
| AAsset* jop::FileLoader::m_asset |
| PHYSFS_File* jop::FileLoader::m_file |
The documentation for this class was generated from the following file: