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 
30 /**
31  * Generic purpose functions that need different
32  * implementations for different platforms.
33  */
34 namespace CrossPlatform
35 {
36 	/// Displays an error message.
37 	void showError(const std::string &error);
38 	/// Finds the game's data folders in the system.
39 	std::vector<std::string> findDataFolders();
40 	/// Finds the game's user folders in the system.
41 	std::vector<std::string> findUserFolders();
42 	/// Finds the game's config folder in the system.
43 	std::string findConfigFolder();
44 	/// Gets the path for a data file.
45 	std::string getDataFile(const std::string &filename);
46     /// Gets the path for a data folder
47 	std::string getDataFolder(const std::string &foldername);
48 	/// Creates a folder.
49 	bool createFolder(const std::string &path);
50 	/// Terminates a path.
51 	std::string endPath(const std::string &path);
52 	/// Returns the list of files in a folder.
53 	std::vector<std::string> getFolderContents(const std::string &path, const std::string &ext = "");
54 	/// Returns the list of files in a data folder.
55 	std::vector<std::string> getDataContents(const std::string &path, const std::string &ext = "");
56 	/// Checks if the path is an existing folder.
57 	bool folderExists(const std::string &path);
58 	/// Checks if the path is an existing file.
59 	bool fileExists(const std::string &path);
60 	/// Deletes the specified file.
61 	bool deleteFile(const std::string &path);
62 	/// Gets the basename of a file.
63 	std::string baseFilename(const std::string &path, int(*transform)(int) = 0);
64 	/// Sanitizes the characters in a filename.
65 	std::string sanitizeFilename(const std::string &filename);
66 	/// Removes the extension from a file.
67 	std::string noExt(const std::string &file);
68 	/// Gets the system locale.
69 	std::string getLocale();
70 	/// Checks if an event is a quit shortcut.
71 	bool isQuitShortcut(const SDL_Event &ev);
72 	/// Gets the modified date of a file.
73 	time_t getDateModified(const std::string &path);
74 	/// Converts a timestamp to a string.
75 	std::pair<std::wstring, std::wstring> timeToString(time_t time);
76 	/// Compares two strings by natural order.
77 	bool naturalCompare(const std::wstring &a, const std::wstring &b);
78 	/// Move/rename a file between paths.
79 	bool moveFile(const std::string &src, const std::string &dest);
80 	/// Flashes the game window.
81 	void flashWindow();
82 	/// Gets the DOS-style executable path.
83 	std::string getDosPath();
84 	/// Sets the window icon.
85 	void setWindowIcon(int winResource, const std::string &unixPath);
86 }
87 
88 }
89 
90 #endif
91