-
Notifications
You must be signed in to change notification settings - Fork 0
/
VCMIDirs.h
56 lines (48 loc) · 1.15 KB
/
VCMIDirs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef __VCMIDIRS_H__
#define __VCMIDIRS_H__
/*
* UserHome.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#ifndef _WIN32 //we need boost here only on non-win platforms
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
#endif
/// Where to find the various VCMI files. This is mostly useful for linux.
class VCMIDirs {
public:
std::string UserPath;
VCMIDirs()
{
#ifdef _WIN32
UserPath = DATA_DIR;
#else
try {
#ifdef ANDROID
UserPath = DATA_DIR;
#else
// Find vcmi user directory and create it if necessary
std::string home_dir = ".";
if( getenv("HOME") != NULL )
home_dir = getenv("HOME");
UserPath = path(home_dir + "/.vcmi").string();
#endif
create_directory(UserPath);
create_directory(UserPath + "/config");
create_directory(UserPath + "/Games");
/* Home directory can contain some extra maps. */
create_directory(UserPath + "/Maps");
}
catch(const std::exception & e)
{
}
#endif
}
};
extern VCMIDirs GVCMIDirs;
#endif // __VCMIDIRS_H__