MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / addDefaultDirs

Method addDefaultDirs

Source/ResourceMan.cpp:54–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54void cResourceMan::addDefaultDirs() {
55 std::string path;
56
57 // Working Dir
58 mAllPaths.push_back(getcwd());
59
60#ifdef WIN32
61 size_t a = 512;
62 char path1[512];
63 getenv_s(&a, path1, "USERPROFILE");
64 path.append(path1, a - 1);
65
66 if (path.size())
67 addBaseDir(path + "/Documents/");
68#else
69 //Per-user data dir (Flatpak: ~/.var/app/<app-id>/data)
70 char* path1 = std::getenv("XDG_DATA_HOME");
71 if (path1 && *path1) {
72 addBaseDir(std::string(path1) + "/");
73 }
74
75 //XDG_DATA_DIRS
76 path1 = std::getenv("XDG_DATA_DIRS");
77 if (path1) {
78 std::stringstream ss;
79 ss << path1;
80 while (ss.good()) {
81 std::string substr;
82 std::getline(ss, substr, ':');
83 addBaseDir(substr);
84 }
85 }
86 //HOME -> ~/.local/share
87 path1 = std::getenv("HOME");
88 if (path1) {
89 path = path1;
90 addBaseDir(path + "/.local/share/");
91 }
92 //Fallback to /usr/local/share
93 addBaseDir("/usr/local/share/");
94#endif
95}
96
97void cResourceMan::validatePaths() {
98

Callers

nothing calls this directly

Calls 2

push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected