[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Unify windows special-dir handling
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv23056/src/or
Modified Files:
config.c
Log Message:
Unify windows special-dir handling
Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.179
retrieving revision 1.180
diff -u -d -r1.179 -r1.180
--- config.c 17 Oct 2004 01:57:34 -0000 1.179
+++ config.c 17 Oct 2004 03:38:02 -0000 1.180
@@ -520,20 +520,24 @@
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. */
@@ -545,9 +549,19 @@
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
@@ -1178,9 +1192,7 @@
#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;