Represents directories used by Doomseeker to store data. More...
#include <datapaths.h>
Public Types | |
enum | MachineType { x86, x64, Preferred } |
Public Member Functions | |
DataPaths (bool bPortableModeOn=false) | |
QStringList | canWrite () const |
Checks if all directories can be written to. More... | |
bool | createDirectories () |
Creates necessary directories for application run. More... | |
QString | demosDirectoryPath () const |
QStringList | directoriesExist () const |
Checks if all necessary directories exist. More... | |
bool | isPortableModeOn () const |
QString | localDataLocationPath (const QString &subpath=QString()) const |
Path to the directory where large data should be saved. More... | |
const QString & | programDirName () const |
Defaults to PROGRAMS_APPDATA_DIR_NAME. More... | |
QString | programsDataDirectoryPath () const |
Path to directory where this concrete application should store it's data. More... | |
QString | programsDataSupportDirectoryPath () const |
Allows switching from Preferences to Application Support on OS X. More... | |
void | setPortableModeOn (bool b) |
void | setProgramDirName (const QString &name) |
void | setWorkingDirectory (const QString &workingDirectory) |
QString | systemAppDataDirectory (QString append=QString()) const |
Gets path to the root directory for data storage. More... | |
bool | validateAppDataDirectory () |
Checks if the root directory for Doomseeker data storage is accessible. More... | |
const QString & | workingDirectory () const |
Program working directory. More... | |
Static Public Member Functions | |
static DataPaths * | defaultInstance () |
Retrieves default instance that is used throughout the program. More... | |
static void | initDefault (bool bPortableModeOn) |
static QString | programFilesDirectory (MachineType machineType) |
static QStringList | staticDataSearchDirs (const QString &subdir=QString()) |
Paths to directories where program should search for its static data. More... | |
Protected Member Functions | |
bool | tryCreateDirectory (const QDir &rootDir, const QString &dirToCreate) const |
If directory already exists true is returned. More... | |
Static Protected Member Functions | |
static bool | validateDir (const QString &path) |
Represents directories used by Doomseeker to store data.
Since Doomseeker doesn't need to store much all data is stored in a single directory. For portable model this is the same directory as in which Doomseeker.exe resides. Otherwise .doomseeker/ directory can be created in a path depending on the operating system.
Definition at line 43 of file datapaths.h.
QStringList DataPaths::canWrite | ( | ) | const |
Checks if all directories can be written to.
Definition at line 73 of file datapaths.cpp.
bool DataPaths::createDirectories | ( | ) |
Creates necessary directories for application run.
If directories exist nothing happens.
Definition at line 86 of file datapaths.cpp.
|
static |
Retrieves default instance that is used throughout the program.
This instance must first be init with initDefault().
Definition at line 112 of file datapaths.cpp.
QStringList DataPaths::directoriesExist | ( | ) | const |
Checks if all necessary directories exist.
Definition at line 123 of file datapaths.cpp.
QString DataPaths::localDataLocationPath | ( | const QString & | subpath = QString() | ) | const |
Path to the directory where large data should be saved.
This path is supposed to hold data which should be stored only the local file system. If portable mode is on this returns path to program directory with "/.static" appended. If portable mode is off this returns path to QDesktopServices::DataLocation with "/.PROGRAMS_APPDATA_DIR_NAME" appended.
subpath | If specified then this path is appended to the returned path. |
Definition at line 172 of file datapaths.cpp.
const QString & DataPaths::programDirName | ( | ) | const |
Defaults to PROGRAMS_APPDATA_DIR_NAME.
Definition at line 143 of file datapaths.cpp.
|
static |
Retrieves correct path to "Program Files" directory. Windows only.
This exploits environmental variables such as PROGRAMFILES%, PROGRAMFILES(X86)% and ProgramW6432. This method is used to determine the correct path to the "Program Files" directory on Windows (XP and above). Since on *nix systems there is no equivalent it will return an empty string.
Definition at line 194 of file datapaths.cpp.
QString DataPaths::programsDataDirectoryPath | ( | ) | const |
Path to directory where this concrete application should store it's data.
Depending on model (portable or not) and operating system this might point to a number of different directories. However the root dir is determined by calling the systemAppDataDirectory() method and appending string returned by programDirName() getter.
Definition at line 235 of file datapaths.cpp.
QString DataPaths::programsDataSupportDirectoryPath | ( | ) | const |
Allows switching from Preferences to Application Support on OS X.
Same as programsDataDirectoryPath() on other systems or in portable mode.
Definition at line 241 of file datapaths.cpp.
|
static |
Paths to directories where program should search for its static data.
By static data we understand read only files which come preinstalled with the program. These files should reside in known locations.
subdir | If this sub-path is specified then then it's appended to all returned paths. |
Definition at line 255 of file datapaths.cpp.
QString DataPaths::systemAppDataDirectory | ( | QString | append = QString() | ) | const |
Gets path to the root directory for data storage.
If portable mode is ON this points to the application's directory. Otherwise:
For Windows this is determined based on APPDATA% environment variable. If this cannot be found then QDir::home() is used.
On other systems QDir::home() is used directly.
append | - this string will be appended to the returned path. |
Definition at line 273 of file datapaths.cpp.
|
protected |
If directory already exists true is returned.
Definition at line 313 of file datapaths.cpp.
bool DataPaths::validateAppDataDirectory | ( | ) |
Checks if the root directory for Doomseeker data storage is accessible.
Definition at line 323 of file datapaths.cpp.
|
staticprotected |
Definition at line 328 of file datapaths.cpp.
const QString & DataPaths::workingDirectory | ( | ) | const |
Program working directory.
Definition at line 339 of file datapaths.cpp.