MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / getConfigDirName

Function getConfigDirName

src/game/DirectoryNames.cpp:81–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79
80
81std::string getConfigDirName(const char* versionName) {
82 std::string customConfigDir = configDir(0, NULL);
83 if (customConfigDir.size() > 0) {
84 if (versionName)
85#if defined(_WIN32)
86 return customConfigDir + versionName + "\\";
87#else
88 return customConfigDir + versionName + "/";
89#endif
90 else {
91 return customConfigDir;
92 }
93 }
94
95#if defined(_WIN32)
96 std::string name("C:");
97 char dir[MAX_PATH];
98 ITEMIDLIST* idl;
99 if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &idl))) {
100 if (SHGetPathFromIDList(idl, dir)) {
101 struct stat statbuf;
102 if (stat(dir, &statbuf) == 0 && (statbuf.st_mode & _S_IFDIR) != 0) {
103 name = dir;
104 }
105 }
106
107 IMalloc* shalloc;
108 if (SUCCEEDED(SHGetMalloc(&shalloc))) {
109 shalloc->Free(idl);
110 shalloc->Release();
111 }
112 }
113
114 // yes your suposed to have the "my" in front of it. I know it's silly, but it's the MS way.
115 name += "\\My BZFlag Files\\";
116 if (versionName) {
117 name += versionName;
118 name += "\\";
119 }
120 customConfigDir = name;
121 return name;
122
123#elif defined(__APPLE__)
124 std::string name;
125 ::FSRef libraryFolder;
126 ::OSErr err;
127 err = ::FSFindFolder(::kUserDomain, ::kApplicationSupportFolderType, true, &libraryFolder);
128 if (err == ::noErr) {
129 char buff[1024];
130 err = ::FSRefMakePath(&libraryFolder, (UInt8*)buff, sizeof(buff));
131 if (err == ::noErr) {
132 std::strcat(buff, "/BZFlag/");
133 if (versionName) {
134 std::strncat(buff, versionName, 1024 - strlen(buff) - 1);
135 std::strncat(buff, "/", 1024 - strlen(buff) - 1);
136 }
137 name = buff;
138 }

Callers 15

setupStringFunction · 0.85
getCacheDirNameFunction · 0.85
getTempDirNameFunction · 0.85
saveStartupInfoFunction · 0.85
findPluginFunction · 0.85
getOldConfigFileNameFunction · 0.85
getCurrentConfigFileNameFunction · 0.85
findConfigFileFunction · 0.85
getLuaCodeFilenameMethod · 0.85
setupFilenameFunction · 0.85
operator()Method · 0.85
setupVFSFunction · 0.85

Calls 5

configDirFunction · 0.85
ReleaseMethod · 0.80
statClass · 0.70
sizeMethod · 0.45
FreeMethod · 0.45

Tested by

no test coverage detected