X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/e1e3ef08ef3419f4aabcfb3f45ab49a78000cdb7..8ab2aa9fd51a89e06d92a4f7c3792aaa4a08cc71:/lib/home.c?ds=sidebyside diff --git a/lib/home.c b/lib/home.c index 5426f76..3b3166c 100644 --- a/lib/home.c +++ b/lib/home.c @@ -56,25 +56,29 @@ const char *profile_directory(void) { char *t; if(profiledir) return profiledir; + if((t = getenv("DISORDER_HOME"))) + profiledir = t; + else { #if _WIN32 - wchar_t *wpath = 0; - char *appdata; - if(SHGetKnownFolderPath(&FOLDERID_RoamingAppData, 0, NULL, &wpath) != S_OK) { - disorder_error(0, "error calling SHGetKnownFolderPath"); - return 0; - } - t = win_wtomb(wpath); - CoTaskMemFree(wpath); - byte_xasprintf(&profiledir, "%s\\DisOrder", appdata); + wchar_t *wpath = 0; + char *appdata; + if(SHGetKnownFolderPath(&FOLDERID_RoamingAppData, 0, NULL, &wpath) != S_OK) { + disorder_error(0, "error calling SHGetKnownFolderPath"); + return 0; + } + t = win_wtomb(wpath); + CoTaskMemFree(wpath); + byte_xasprintf(&profiledir, "%s\\DisOrder", appdata); #else - struct passwd *pw; - if(!(t = getenv("HOME"))) { - if(!(pw = getpwuid(getuid()))) - disorder_error(0, "user not found in password database"); - t = pw->pw_dir; - } - byte_xasprintf(&profiledir, "%s/.disorder", t); + struct passwd *pw; + if(!(t = getenv("HOME"))) { + if(!(pw = getpwuid(getuid()))) + disorder_error(0, "user not found in password database"); + t = pw->pw_dir; + } + byte_xasprintf(&profiledir, "%s/.disorder", t); #endif + } return profiledir; }