![]() |
OpenXcom
1.0
Open-source clone of the original X-Com
|
Generic purpose functions that need different implementations for different platforms. More...
Functions | |
void | getErrorDialog () |
Determines the available Linux error dialogs. More... | |
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 | searchDataFile (const std::string &filename) |
Searches the data folders and returns the full path for a data file when given a relative path, like "units/zombie.pck". returns the passed-in filename if the file is not found. | |
std::string | searchDataFolder (const std::string &foldername) |
Searches the data folders and returns the full path for a folder when given a relative path, like "common". returns the passed-in dir name if the folder is not found. | |
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... | |
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) |
Returns only the filename from a specified 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 | getExt (const std::string &filename) |
Returns the extension from a filename. More... | |
bool | compareExt (const std::string &filename, const std::string &extension) |
Compares the extension in a filename (case-insensitive). 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::string, std::string > | timeToString (time_t time) |
Converts a date/time into a human-readable string using the ISO 8601 standard. 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, const std::string &unixPath) |
Sets the window titlebar icon. More... | |
void | stackTrace (void *ctx) |
Logs the stack back trace leading up to this function call. More... | |
std::string | now () |
Generates a timestamp of the current time. More... | |
void | crashDump (void *ex, const std::string &err) |
Logs the details of this crash and shows an error. More... | |
Generic purpose functions that need different implementations for different platforms.
std::string OpenXcom::CrossPlatform::baseFilename | ( | const std::string & | path | ) |
Returns only the filename from a specified path.
Gets the pathless filename of a file.
path | Full path. |
bool OpenXcom::CrossPlatform::compareExt | ( | const std::string & | filename, |
const std::string & | extension | ||
) |
Compares the extension in a filename (case-insensitive).
Compares the extension of a filename.
filename | Filename to compare. |
extension | Extension to compare to. |
void OpenXcom::CrossPlatform::crashDump | ( | void * | ex, |
const std::string & | err | ||
) |
Logs the details of this crash and shows an error.
Produces a crash dump.
ex | Pointer to exception data (PEXCEPTION_POINTERS on Windows, signal int on Unix) |
err | Exception message, if any. |
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. |
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.
void OpenXcom::CrossPlatform::getErrorDialog | ( | ) |
Determines the available Linux error dialogs.
Gets the available error dialog.
std::string OpenXcom::CrossPlatform::getExt | ( | const std::string & | filename | ) |
Returns the extension from a filename.
Gets the extension from a filename.
Only the last dot is considered.
filename | Original filename. |
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. |
std::string OpenXcom::CrossPlatform::noExt | ( | const std::string & | filename | ) |
Removes the extension from a filename.
Only the last dot is considered.
filename | Original filename. |
std::string OpenXcom::CrossPlatform::now | ( | ) |
Generates a timestamp of the current time.
Produces a quick timestamp.
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::setWindowIcon | ( | int | , |
const std::string & | unixPath | ||
) |
Sets the window titlebar icon.
Sets the window icon.
For Windows, use the embedded resource icon. For other systems, use a PNG icon.
winResource | ID for Windows icon. |
unixPath | Path to PNG icon for Unix. |
void OpenXcom::CrossPlatform::showError | ( | const std::string & | error | ) |
Displays a message box with an error message.
Displays an error message.
error | Error message. |
void OpenXcom::CrossPlatform::stackTrace | ( | void * | ctx | ) |
Logs the stack back trace leading up to this function call.
Produces a stack trace.
ctx | Pointer to stack context (PCONTEXT on Windows), NULL to use current context. |
std::pair< std::string, std::string > 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. |