aboutsummaryrefslogtreecommitdiffhomepage
path: root/path.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-12-03 02:25:08 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-12-03 02:25:08 -0800
commitb9283d48b570e66650a6443bc7ebb8048f589546 (patch)
tree982ec5156d4016a3345af94b3025a926074d9489 /path.cpp
parent33fc5c99ea067caa6634d34e02b4eeb89672b6ea (diff)
Added a history speed test
Profile driven caching of config directory Style fixes
Diffstat (limited to 'path.cpp')
-rw-r--r--path.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/path.cpp b/path.cpp
index ef53b1f9..679e898a 100644
--- a/path.cpp
+++ b/path.cpp
@@ -323,9 +323,9 @@ bool path_can_be_implicit_cd(const wcstring &path, wcstring *out_path, const wch
return result;
}
-bool path_get_config(wcstring &path)
+static wcstring path_create_config()
{
- int done = 0;
+ bool done = false;
wcstring res;
const env_var_t xdg_dir = env_get_string(L"XDG_CONFIG_HOME");
@@ -334,7 +334,7 @@ bool path_get_config(wcstring &path)
res = xdg_dir + L"/fish";
if (!create_directory(res))
{
- done = 1;
+ done = true;
}
}
else
@@ -345,22 +345,26 @@ bool path_get_config(wcstring &path)
res = home + L"/.config/fish";
if (!create_directory(res))
{
- done = 1;
+ done = true;
}
}
}
- if (done)
- {
- path = res;
- return true;
- }
- else
+ if (! done)
{
+ res.clear();
+
debug(0, _(L"Unable to create a configuration directory for fish. Your personal settings will not be saved. Please set the $XDG_CONFIG_HOME variable to a directory where the current user has write access."));
- return false;
}
+ return res;
+}
+/* Cache the config path */
+bool path_get_config(wcstring &path)
+{
+ static const wcstring result = path_create_config();
+ path = result;
+ return ! result.empty();
}
static void replace_all(wcstring &str, const wchar_t *needle, const wchar_t *replacement)