options->NumCpus = 1;
}
-static char *
-get_default_conf_file(void)
-{
#ifdef MS_WINDOWS
+static char *get_windows_conf_root(void)
+{
+ static int is_set = 0;
+ static char path[MAX_PATH+1];
+
LPITEMIDLIST idl;
IMalloc *m;
HRESULT result;
- char *path = tor_malloc(MAX_PATH);
+
+ if (is_set)
+ return path;
+
/* Find X:\documents and settings\username\applicatation data\ .
* We would use SHGetSpecialFolder path, but that wasn't added until IE4.
*/
if (!SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA,
&idl))) {
- tor_free(path);
return NULL;
}
/* Convert the path from an "ID List" (whatever that is!) to a path. */
m->lpVtbl->Release(m);
}
if (!SUCCEEDED(result)) {
- tor_free(path);
return NULL;
}
+ is_set = 1;
+ return path;
+}
+#endif
+
+static char *
+get_default_conf_file(void)
+{
+#ifdef MS_WINDOWS
+ char *path = tor_malloc(MAX_PATH);
+ strlcpy(path, get_windows_conf_root(), MAX_PATH);
strlcat(path,"\\tor\\torrc",MAX_PATH);
return path;
#else
#ifdef MS_WINDOWS
char *p;
p = tor_malloc(MAX_PATH);
- if (!SUCCEEDED(SHGetSpecialFolderPath(NULL, p, CSIDL_APPDATA, 1))) {
- strlcpy(p,CONFDIR, MAX_PATH);
- }
+ strlcpy(p,get_windows_conf_root(),MAX_PATH);
strlcat(p,"\\tor",MAX_PATH);
options->DataDirectory = p;
return p;