34 |
#include "ltdl.h" |
#include "ltdl.h" |
35 |
|
|
36 |
#include <string> |
#include <string> |
37 |
|
#include "base/file.h" |
38 |
|
|
39 |
namespace base |
namespace base |
40 |
{ |
{ |
63 |
* Before any method of this class can be used, it must be initialized. |
* Before any method of this class can be used, it must be initialized. |
64 |
* @param game name of the game the data files queried belong to. |
* @param game name of the game the data files queried belong to. |
65 |
* @param userdatadir optional, user supplied data directory. |
* @param userdatadir optional, user supplied data directory. |
66 |
|
* @return \c true if successful, \c false otherwise |
67 |
*/ |
*/ |
68 |
void init (const std::string & game, const std::string & userdatadir = ""); |
bool init (const std::string & game, const std::string & userdatadir = ""); |
69 |
|
|
70 |
|
/** |
71 |
|
* While loading a saved game, the name of the saved game directory must |
72 |
|
* be passed, so that it can be temporarily included into the Adonthell |
73 |
|
* search path. To remove it after loading, pass an empty string ("") |
74 |
|
* to this method. |
75 |
|
* @param dir the saved game directory. |
76 |
|
*/ |
77 |
|
void set_save_dir (const std::string & dir); |
78 |
|
|
79 |
|
/** |
80 |
|
* Try to open the given file at the given location. Searches for the |
81 |
|
* file in saved game dir (if set before with set_save_dir()), the |
82 |
|
* user supplied data directory and finally the built in data directory. |
83 |
|
* @param file a igzstream to be opened. |
84 |
|
* @param location file to locate within the Adonthell search path. |
85 |
|
* @return \c true on success, \c false if the file doesn't exist. |
86 |
|
*/ |
87 |
|
bool open (igzstream & file, const std::string & location); |
88 |
|
|
89 |
|
/** |
90 |
|
* Return the configuration data directory. |
91 |
|
* @return path to the Adonthell configuration directory. |
92 |
|
*/ |
93 |
|
std::string cfg_data_dir () const { return CfgDataDir; } |
94 |
|
|
95 |
private: |
private: |
96 |
|
/** |
97 |
|
* Check whether the given directory exists and is accessible. |
98 |
|
* @param path an absolute path to check. |
99 |
|
* @return \c true if directory can be opened, \c false otherwise. |
100 |
|
*/ |
101 |
|
bool exists (const std::string & path); |
102 |
|
|
103 |
/// directory of the saved game currently being loaded (if any) |
/// directory of the saved game currently being loaded (if any) |
104 |
std::string SaveDataDir; |
std::string SaveDataDir; |
105 |
/// user supplied game data directory (if any) |
/// user supplied game data directory (if any) |
106 |
std::string UserDataDir; |
std::string UserDataDir; |
107 |
// builtin game data directory (mandatory) |
// builtin game data directory (mandatory) |
108 |
std::string GameDataDir; |
std::string GameDataDir; |
109 |
|
/// the (OS dependent) path to configuration and saved games |
110 |
|
std::string CfgDataDir; |
111 |
|
/// whether to include a saved game directory in Adonthell's search path |
112 |
|
bool IncludeSaveDir; |
113 |
|
/// whether to include user supplied data directory in search path |
114 |
|
bool IncludeUserDir; |
115 |
}; |
}; |
116 |
} |
} |
117 |
|
|