aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-14 02:04:43 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-14 02:04:43 +0000
commit8b325c142edce4baea24ac229a55c2663f63c12f (patch)
tree6c0f8a4cfa99cd6f63d9d4f4289877bcff567eed
parent0d5a847f12724d1a86898ca3246850c06ceaebf1 (diff)
downloadtor-8b325c142edce4baea24ac229a55c2663f63c12f.tar
tor-8b325c142edce4baea24ac229a55c2663f63c12f.tar.gz
Patch from "J Doe": Use SHGetSpecialFolderLocation instead of
SHGetSpecialFolderPath in order to find application data folder. Apparently, until IE 4 (!?) came out, nobody realized that programmers might like to get paths as strings. Clearly, a fancy pseudo-OO list of "identifiers" is a far more convenient way to deal with these things. And while we're being OO, why return object that you can free with free()? Instead, let's make the user get a handle to an abstract allocation object, and ask it to free the fancy list, and then ask it to release itself. Won't that be fun and convenient? Navigating ancient Win32 APIs is like bikini-waxing creatures from HP Lovecraft: to do a good job you must understand what's going on... but the understanding itself can blast your sanity. svn:r2480
-rw-r--r--src/or/config.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/or/config.c b/src/or/config.c
index d79070549..342f3f67e 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -486,8 +486,27 @@ static void init_options(or_options_t *options) {
static char *get_default_conf_file(void)
{
#ifdef MS_WINDOWS
+ LPITEMIDLIST idl;
+ IMalloc *m;
+ HRESULT result;
char *path = tor_malloc(MAX_PATH);
- if (!SUCCEEDED(SHGetSpecialFolderPath(NULL, path, CSIDL_APPDATA, 1))) {
+ /* 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. */
+ result = SHGetPathFromIDList(idl, path);
+ /* Now we need to free the */
+ SHGetMalloc(&m);
+ if (m) {
+ m->lpVtbl->Free(m, idl);
+ m->lpVtbl->Release(m);
+ }
+ if (!SUCCEEDED(result)) {
tor_free(path);
return NULL;
}