diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-10-17 03:38:02 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-10-17 03:38:02 +0000 |
commit | 6d1e1b7f46494c1785b49ee996c2e4e2ca668056 (patch) | |
tree | 00c424bfd69cffa8c09e927b26b96057717d3bb3 | |
parent | 376d483d0a0f1a0622f9fb1463be7ba8243cc4bc (diff) | |
download | tor-6d1e1b7f46494c1785b49ee996c2e4e2ca668056.tar tor-6d1e1b7f46494c1785b49ee996c2e4e2ca668056.tar.gz |
Unify windows special-dir handling
svn:r2552
-rw-r--r-- | src/or/config.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/or/config.c b/src/or/config.c index f0746b79a..9ea398783 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -520,20 +520,24 @@ init_options(or_options_t *options) 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 @@ get_default_conf_file(void) 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 @@ get_data_directory(or_options_t *options) #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; |