MCPcopy Create free account
hub / github.com/assaultcube/AC / sethomedir

Function sethomedir

source/src/stream.cpp:176–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174#endif
175
176void sethomedir(const char *dir)
177{
178 string tmpdir;
179 copystring(tmpdir, dir);
180
181#ifdef WIN32
182 const char substitute[] = "?MYDOCUMENTS?";
183 if(!strncmp(dir, substitute, strlen(substitute)))
184 {
185 const char *regpath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
186 char *mydocuments = getregszvalue(HKEY_CURRENT_USER, regpath, "Personal");
187 if(mydocuments)
188 {
189 formatstring(tmpdir)("%s%s", mydocuments, dir+strlen(substitute));
190 delete[] mydocuments;
191 }
192 else
193 {
194 printf("failed to retrieve 'Personal' path from '%s'\n", regpath);
195 }
196 }
197#endif
198
199 if(fixpackagedir(tmpdir) > 0)
200 {
201#ifndef STANDALONE
202 clientlogf("Using home directory: %s", tmpdir);
203#endif
204 copystring(homedir, tmpdir);
205 createdir(homedir);
206 }
207}
208
209bool havehomedir()
210{

Callers 1

main.cppFile · 0.85

Calls 5

copystringFunction · 0.85
getregszvalueFunction · 0.85
fixpackagedirFunction · 0.85
clientlogfFunction · 0.85
createdirFunction · 0.85

Tested by

no test coverage detected