|
Hymn to Beauty
C++ 3D Engine
|
Functionality to interact with the file system. More...
Functions | |
| bool | FileExists (const char *filename) |
| Check if a file exists. More... | |
| void | Copy (const char *source, const char *destination) |
| Copy a file. More... | |
| void | CreateDirectory (const char *filename) |
| Create a directory if it does not already exist. More... | |
| bool | DeleteDirectory (const char *filename) |
| Delete a directory if it is empty. More... | |
| std::vector< std::string > | DirectoryContents (const std::string &directoryName, unsigned int type=FILE|DIRECTORY) |
| Get all the contents of a directory. More... | |
| std::string | DataPath (const char *appName) |
| Get save path for application data folder. More... | |
| std::string | DataPath (const char *appName, const char *filename) |
| Get save path for application data. More... | |
| std::string | GetParentDirectory (const std::string &path) |
| Get the parent directory of a path. More... | |
| std::string | GetExtension (const std::string &filename) |
| Get the extension part of a filename. More... | |
| std::string | GetName (const std::string &filepath) |
| Get the name of the file without the extension. More... | |
| std::string | GetDirectory (const std::string &path) |
| Get the directory part for a path (including the final delimiter). More... | |
| void | ExecuteProgram (const std::string &path, const std::string &arguments) |
| Execute a program asynchronously. More... | |
Variables | |
| const char | DELIMITER = '/' |
| Delimiter, '\' on Windows, '/' elsewhere. More... | |
| const unsigned int | FILE = 1 |
| A file. More... | |
| const unsigned int | DIRECTORY = 2 |
| A directory. More... | |
Functionality to interact with the file system.
| void FileSystem::Copy | ( | const char * | source, |
| const char * | destination | ||
| ) |
Copy a file.
| source | Source to copy. |
| destination | Destination to copy to. |
| void FileSystem::CreateDirectory | ( | const char * | filename | ) |
Create a directory if it does not already exist.
Permission for new directory is 0777 on Unix.
| filename | Filename (either absolute or relative) for the directory to create. |
| std::string FileSystem::DataPath | ( | const char * | appName | ) |
Get save path for application data folder.
The application data folder is created if it does not already exist. On Windows, this is <User>\AppData\Roaming\<AppName>. On MacOS, this is ~/Library/Application Support/<AppName>. On Linux, this is ~/.local/share/<AppName>.
| appName | The name of the app/game. |
| std::string FileSystem::DataPath | ( | const char * | appName, |
| const char * | filename | ||
| ) |
Get save path for application data.
The application data folder is created if it does not already exist. On Windows, this is <User>\AppData\Roaming\<AppName>\<Filename>. On MacOS, this is ~/Library/Application Support/<AppName>/<Filename>. On Linux, this is ~/.local/share/<AppName>/<Filename>.
| appName | The name of the app/game. |
| filename | Filename, eg. "settings.ini". |
| bool FileSystem::DeleteDirectory | ( | const char * | filename | ) |
Delete a directory if it is empty.
| filename | The path of the directory to remove. |
| std::vector< std::string > FileSystem::DirectoryContents | ( | const std::string & | directoryName, |
| unsigned int | type = FILE|DIRECTORY |
||
| ) |
Get all the contents of a directory.
| directoryName | Path to the directory to scan. |
| type | Type of content to get, FILE, DIRECTORY or both (use | to combine). |
| void FileSystem::ExecuteProgram | ( | const std::string & | path, |
| const std::string & | arguments | ||
| ) |
Execute a program asynchronously.
| path | The path to the program to execute. |
| arguments | The arguments to the program. |
| bool FileSystem::FileExists | ( | const char * | filename | ) |
Check if a file exists.
Works for directories as well.
| filename | Filename (either relative or absolute) to check. |
| std::string FileSystem::GetDirectory | ( | const std::string & | path | ) |
Get the directory part for a path (including the final delimiter).
| path | The path to get the directory part of. |
| std::string FileSystem::GetExtension | ( | const std::string & | filename | ) |
Get the extension part of a filename.
| filename | The filename to check. |
| std::string FileSystem::GetName | ( | const std::string & | filepath | ) |
Get the name of the file without the extension.
| filepath | The datapath to the file. |
| std::string FileSystem::GetParentDirectory | ( | const std::string & | path | ) |
Get the parent directory of a path.
| path | Absolute path to get the parent directory of. |
| const char FileSystem::DELIMITER = '/' |
Delimiter, '\' on Windows, '/' elsewhere.
| const unsigned int FileSystem::DIRECTORY = 2 |
A directory.
| const unsigned int FileSystem::FILE = 1 |
A file.