diff options
author | 2012-02-05 16:42:24 -0800 | |
---|---|---|
committer | 2012-02-05 16:42:24 -0800 | |
commit | 5ad6849d4e6aa76a72b671b50b143ef80d381a75 (patch) | |
tree | b381f5b239085d378af1865d82f549e33ba9827f /path.cpp | |
parent | 7fcf25a78f7241b9ee50ea9d5cbf2b0646c45b78 (diff) |
Work on new history implementation
Diffstat (limited to 'path.cpp')
-rw-r--r-- | path.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -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 ) |