OpenXcom
1.0
Open-source clone of the original X-Com
|
Generic purpose functions that need different implementations for different platforms. More...
Functions | |
void | showError (const std::string &error) |
Displays a message box with an error message. More... | |
std::vector< std::string > | findDataFolders () |
Builds a list of predefined paths for the Data folder according to the running system. More... | |
std::vector< std::string > | findUserFolders () |
Builds a list of predefined paths for the User folder according to the running system. More... | |
std::string | findConfigFolder () |
Finds the Config folder according to the running system. More... | |
std::string | caseInsensitive (const std::string &base, const std::string &path) |
Takes a path and tries to find it based on the system's case-sensitivity. More... | |
std::string | caseInsensitiveFolder (const std::string &base, const std::string &path) |
Takes a path and tries to find it based on the system's case-sensitivity. More... | |
std::string | getDataFile (const std::string &filename) |
Takes a filename and tries to find it in the game's Data folders, accounting for the system's case-sensitivity and path style. More... | |
std::string | getDataFolder (const std::string &foldername) |
Takes a foldername and tries to find it in the game's Data folders, accounting for the system's case-sensitivity and path style. More... | |
bool | createFolder (const std::string &path) |
Creates a folder at the specified path. More... | |
std::string | endPath (const std::string &path) |
Adds an ending slash to a path if necessary. More... | |
std::vector< std::string > | getFolderContents (const std::string &path, const std::string &ext) |
Gets the name of all the files contained in a certain folder. More... | |
std::vector< std::string > | getDataContents (const std::string &folder, const std::string &ext) |
Gets the name of all the files contained in a Data subfolder. More... | |
bool | folderExists (const std::string &path) |
Checks if a certain path exists and is a folder. More... | |
bool | fileExists (const std::string &path) |
Checks if a certain path exists and is a file. More... | |
bool | deleteFile (const std::string &path) |
Removes a file from the specified path. More... | |
std::string | baseFilename (const std::string &path, int(*transform)(int)) |
Gets the base filename of a path. More... | |
std::string | sanitizeFilename (const std::string &filename) |
Replaces invalid filesystem characters with _. More... | |
std::string | noExt (const std::string &filename) |
Removes the extension from a filename. More... | |
std::string | getLocale () |
Gets the current locale of the system in language-COUNTRY format. More... | |
bool | isQuitShortcut (const SDL_Event &ev) |
Checks if the system's default quit shortcut was pressed. More... | |
time_t | getDateModified (const std::string &path) |
Gets the last modified date of a file. More... | |
std::pair< std::wstring, std::wstring > | timeToString (time_t time) |
Converts a date/time into a human-readable string using the ISO 8601 standard. More... | |
bool | naturalCompare (const std::wstring &a, const std::wstring &b) |
Compares two Unicode strings using natural human ordering. More... | |
bool | moveFile (const std::string &src, const std::string &dest) |
Moves a file from one path to another, replacing any existing file. More... | |
void | flashWindow () |
Notifies the user that maybe he should have a look. More... | |
std::string | getDosPath () |
Gets the executable path in DOS-style (short) form. More... | |
void | setWindowIcon (int winResource, const std::string &unixPath) |
Sets the window icon. | |
Generic purpose functions that need different implementations for different platforms.
std::string OpenXcom::CrossPlatform::baseFilename | ( | const std::string & | path, |
int(*)(int) | transform | ||
) |
Gets the base filename of a path.
Gets the basename of a file.
path | Full path to file. |
transform | Optional function to transform the filename. |
std::string OpenXcom::CrossPlatform::caseInsensitive | ( | const std::string & | base, |
const std::string & | path | ||
) |
Takes a path and tries to find it based on the system's case-sensitivity.
base | Base unaltered path. |
path | Full path to check for casing. |
std::string OpenXcom::CrossPlatform::caseInsensitiveFolder | ( | const std::string & | base, |
const std::string & | path | ||
) |
Takes a path and tries to find it based on the system's case-sensitivity.
base | Base unaltered path. |
path | Full path to check for casing. |
bool OpenXcom::CrossPlatform::createFolder | ( | const std::string & | path | ) |
Creates a folder at the specified path.
Creates a folder.
path | Full path. |
bool OpenXcom::CrossPlatform::deleteFile | ( | const std::string & | path | ) |
Removes a file from the specified path.
Deletes the specified file.
path | Full path to file. |
std::string OpenXcom::CrossPlatform::endPath | ( | const std::string & | path | ) |
Adds an ending slash to a path if necessary.
Terminates a path.
path | Folder path. |
bool OpenXcom::CrossPlatform::fileExists | ( | const std::string & | path | ) |
Checks if a certain path exists and is a file.
Checks if the path is an existing file.
path | Full path to file. |
std::string OpenXcom::CrossPlatform::findConfigFolder | ( | ) |
Finds the Config folder according to the running system.
Finds the game's config folder in the system.
std::vector< std::string > OpenXcom::CrossPlatform::findDataFolders | ( | ) |
Builds a list of predefined paths for the Data folder according to the running system.
Finds the game's data folders in the system.
std::vector< std::string > OpenXcom::CrossPlatform::findUserFolders | ( | ) |
Builds a list of predefined paths for the User folder according to the running system.
Finds the game's user folders in the system.
void OpenXcom::CrossPlatform::flashWindow | ( | ) |
Notifies the user that maybe he should have a look.
Flashes the game window.
bool OpenXcom::CrossPlatform::folderExists | ( | const std::string & | path | ) |
Checks if a certain path exists and is a folder.
Checks if the path is an existing folder.
path | Full path to folder. |
std::vector< std::string > OpenXcom::CrossPlatform::getDataContents | ( | const std::string & | folder, |
const std::string & | ext | ||
) |
Gets the name of all the files contained in a Data subfolder.
Returns the list of files in a data folder.
Repeated files are ignored.
folder | Path to the data folder. |
ext | Extension of files ("" if it doesn't matter). |
std::string OpenXcom::CrossPlatform::getDataFile | ( | const std::string & | filename | ) |
Takes a filename and tries to find it in the game's Data folders, accounting for the system's case-sensitivity and path style.
Gets the path for a data file.
filename | Original filename. |
std::string OpenXcom::CrossPlatform::getDataFolder | ( | const std::string & | foldername | ) |
Takes a foldername and tries to find it in the game's Data folders, accounting for the system's case-sensitivity and path style.
Gets the path for a data folder.
foldername | Original foldername. |
time_t OpenXcom::CrossPlatform::getDateModified | ( | const std::string & | path | ) |
Gets the last modified date of a file.
Gets the modified date of a file.
path | Full path to file. |
std::string OpenXcom::CrossPlatform::getDosPath | ( | ) |
Gets the executable path in DOS-style (short) form.
Gets the DOS-style executable path.
For non-Windows systems, just use a dummy path.
std::vector< std::string > OpenXcom::CrossPlatform::getFolderContents | ( | const std::string & | path, |
const std::string & | ext | ||
) |
Gets the name of all the files contained in a certain folder.
Returns the list of files in a folder.
path | Full path to folder. |
ext | Extension of files ("" if it doesn't matter). |
std::string OpenXcom::CrossPlatform::getLocale | ( | ) |
Gets the current locale of the system in language-COUNTRY format.
Gets the system locale.
bool OpenXcom::CrossPlatform::isQuitShortcut | ( | const SDL_Event & | ev | ) |
Checks if the system's default quit shortcut was pressed.
Checks if an event is a quit shortcut.
ev | SDL event. |
bool OpenXcom::CrossPlatform::moveFile | ( | const std::string & | src, |
const std::string & | dest | ||
) |
Moves a file from one path to another, replacing any existing file.
Move/rename a file between paths.
src | Source path. |
dest | Destination path. |
bool OpenXcom::CrossPlatform::naturalCompare | ( | const std::wstring & | a, |
const std::wstring & | b | ||
) |
Compares two Unicode strings using natural human ordering.
Compares two strings by natural order.
a | String A. |
b | String B. |
std::string OpenXcom::CrossPlatform::noExt | ( | const std::string & | filename | ) |
Removes the extension from a filename.
Removes the extension from a file.
filename | Original filename. |
std::string OpenXcom::CrossPlatform::sanitizeFilename | ( | const std::string & | filename | ) |
Replaces invalid filesystem characters with _.
Sanitizes the characters in a filename.
filename | Original filename. |
void OpenXcom::CrossPlatform::showError | ( | const std::string & | error | ) |
Displays a message box with an error message.
Displays an error message.
error | Error message. |
std::pair< std::wstring, std::wstring > OpenXcom::CrossPlatform::timeToString | ( | time_t | time | ) |
Converts a date/time into a human-readable string using the ISO 8601 standard.
Converts a timestamp to a string.
time | Value in timestamp format. |