File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 7
7
8
8
namespace fs {
9
9
10
+ #ifdef _WIN32
11
+ #define SEP " \\ "
12
+ #else
13
+ #define SEP " /"
14
+ #endif
15
+
10
16
inline std::string homedir () {
11
17
const char * homedir = getenv (" HOME" );
12
18
if (!homedir)
@@ -15,6 +21,36 @@ namespace fs {
15
21
K_ERROR (GENERAL, " Unable to locate home directory." );
16
22
return homedir;
17
23
}
24
+
25
+ inline std::string configdir (std::string apppath = std::string()) {
26
+ std::string r;
27
+ bool add_config=false ;
28
+ const char * cdir = getenv (" XDG_CONFIG_PATH" );
29
+ if (!cdir){
30
+ cdir = getenv (" HOME" );
31
+ add_config=true ;
32
+ }
33
+ if (!cdir){
34
+ cdir = getenv (" HOMEPATH" );
35
+ add_config=true ;
36
+ }
37
+ if (!cdir){
38
+ K_ERROR (GENERAL, " Unable to locate home directory." );
39
+ }
40
+ if (add_config)
41
+ {
42
+ #ifdef _WIN32
43
+ r = std::string (cdir);
44
+ #else
45
+ r = std::string (cdir) + SEP + " .config" ;
46
+ #endif
47
+ }
48
+ else
49
+ r = cdir;
50
+ if (not apppath.empty ())
51
+ return r + SEP + apppath;
52
+ return r;
53
+ }
18
54
}
19
55
20
56
#endif
You can’t perform that action at this time.
0 commit comments