OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CrossPlatform.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_CROSSPLATFORM_H
20 #define OPENXCOM_CROSSPLATFORM_H
21 
22 #include <SDL.h>
23 #include <string>
24 #include <vector>
25 #include <utility>
26 
27 namespace OpenXcom
28 {
29 
34 namespace CrossPlatform
35 {
37  void showError(const std::string &error);
39  std::vector<std::string> findDataFolders();
41  std::vector<std::string> findUserFolders();
43  std::string findConfigFolder();
45  std::string getDataFile(const std::string &filename);
47  std::string getDataFolder(const std::string &foldername);
49  bool createFolder(const std::string &path);
51  std::string endPath(const std::string &path);
53  std::vector<std::string> getFolderContents(const std::string &path, const std::string &ext = "");
55  std::vector<std::string> getDataContents(const std::string &path, const std::string &ext = "");
57  bool folderExists(const std::string &path);
59  bool fileExists(const std::string &path);
61  bool deleteFile(const std::string &path);
63  std::string baseFilename(const std::string &path, int(*transform)(int) = 0);
65  std::string sanitizeFilename(const std::string &filename);
67  std::string noExt(const std::string &file);
69  std::string getLocale();
71  bool isQuitShortcut(const SDL_Event &ev);
73  time_t getDateModified(const std::string &path);
75  std::pair<std::wstring, std::wstring> timeToString(time_t time);
77  bool naturalCompare(const std::wstring &a, const std::wstring &b);
79  bool moveFile(const std::string &src, const std::string &dest);
81  void flashWindow();
83  std::string getDosPath();
85  void setWindowIcon(int winResource, const std::string &unixPath);
86 }
87 
88 }
89 
90 #endif
bool folderExists(const std::string &path)
Checks if a certain path exists and is a folder.
Definition: CrossPlatform.cpp:598
time_t getDateModified(const std::string &path)
Gets the last modified date of a file.
Definition: CrossPlatform.cpp:786
std::string noExt(const std::string &filename)
Removes the extension from a filename.
Definition: CrossPlatform.cpp:707
void showError(const std::string &error)
Displays a message box with an error message.
Definition: CrossPlatform.cpp:78
std::string getLocale()
Gets the current locale of the system in language-COUNTRY format.
Definition: CrossPlatform.cpp:721
bool isQuitShortcut(const SDL_Event &ev)
Checks if the system's default quit shortcut was pressed.
Definition: CrossPlatform.cpp:766
bool naturalCompare(const std::wstring &a, const std::wstring &b)
Compares two Unicode strings using natural human ordering.
Definition: CrossPlatform.cpp:851
bool moveFile(const std::string &src, const std::string &dest)
Moves a file from one path to another, replacing any existing file.
Definition: CrossPlatform.cpp:870
std::string findConfigFolder()
Finds the Config folder according to the running system.
Definition: CrossPlatform.cpp:275
bool deleteFile(const std::string &path)
Removes a file from the specified path.
Definition: CrossPlatform.cpp:644
std::string sanitizeFilename(const std::string &filename)
Replaces invalid filesystem characters with _.
Definition: CrossPlatform.cpp:683
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.
Definition: CrossPlatform.cpp:555
std::string endPath(const std::string &path)
Adds an ending slash to a path if necessary.
Definition: CrossPlatform.cpp:484
std::vector< std::string > findDataFolders()
Builds a list of predefined paths for the Data folder according to the running system.
Definition: CrossPlatform.cpp:112
void flashWindow()
Notifies the user that maybe he should have a look.
Definition: CrossPlatform.cpp:882
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-se...
Definition: CrossPlatform.cpp:388
std::string baseFilename(const std::string &path, int(*transform)(int))
Gets the base filename of a path.
Definition: CrossPlatform.cpp:659
bool fileExists(const std::string &path)
Checks if a certain path exists and is a file.
Definition: CrossPlatform.cpp:621
std::pair< std::wstring, std::wstring > timeToString(time_t time)
Converts a date/time into a human-readable string using the ISO 8601 standard.
Definition: CrossPlatform.cpp:820
void setWindowIcon(int winResource, const std::string &unixPath)
Sets the window icon.
Definition: CrossPlatform.cpp:941
std::string getDosPath()
Gets the executable path in DOS-style (short) form.
Definition: CrossPlatform.cpp:900
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-...
Definition: CrossPlatform.cpp:424
std::vector< std::string > findUserFolders()
Builds a list of predefined paths for the User folder according to the running system.
Definition: CrossPlatform.cpp:204
bool createFolder(const std::string &path)
Creates a folder at the specified path.
Definition: CrossPlatform.cpp:460
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.
Definition: CrossPlatform.cpp:498