| 174 | #endif |
| 175 | |
| 176 | void 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 | |
| 209 | bool havehomedir() |
| 210 | { |
no test coverage detected