aboutsummaryrefslogtreecommitdiffhomepage
path: root/path.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-05 16:42:24 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-05 16:42:24 -0800
commit5ad6849d4e6aa76a72b671b50b143ef80d381a75 (patch)
treeb381f5b239085d378af1865d82f549e33ba9827f /path.cpp
parent7fcf25a78f7241b9ee50ea9d5cbf2b0646c45b78 (diff)
Work on new history implementation
Diffstat (limited to 'path.cpp')
-rw-r--r--path.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/path.cpp b/path.cpp
index 60ce5c5d..407448e3 100644
--- a/path.cpp
+++ b/path.cpp
@@ -471,8 +471,47 @@ wchar_t *path_get_config( void *context)
{
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 0;
+ }
+}
+
+bool path_get_config(wcstring &path)
+{
+ int done = 0;
+ wcstring res;
+
+ const env_var_t xdg_dir = env_get_string( L"XDG_CONFIG_HOME" );
+ if( ! xdg_dir.missing() )
+ {
+ res = xdg_dir + L"/fish";
+ if( !create_directory( res.c_str() ) )
+ {
+ done = 1;
+ }
+ }
+ else
+ {
+ const env_var_t home = env_get_string( L"HOME" );
+ if( ! home.missing() )
+ {
+ res = home + L"/.config/fish";
+ if( !create_directory( res.c_str() ) )
+ {
+ done = 1;
+ }
+ }
}
+ if( done )
+ {
+ path = res;
+ return true;
+ }
+ else
+ {
+ 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;
+ }
+
}
wchar_t *path_make_canonical( void *context, const wchar_t *path )