diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2014-10-31 01:15:50 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2014-10-31 01:15:50 -0700 |
commit | 7ac593273e25d5ce39104dc1752660a43a29f61d (patch) | |
tree | 1f0a18a2f49a61460ff8d7c1c3de375af37395d4 /path.cpp | |
parent | a529fc9d83295fdf9418436b68d056162ba8231b (diff) |
Remove a bunch of dead code identified by cppcheck
Diffstat (limited to 'path.cpp')
-rw-r--r-- | path.cpp | 79 |
1 files changed, 0 insertions, 79 deletions
@@ -141,85 +141,6 @@ bool path_get_path(const wcstring &cmd, wcstring *out_path) return path_get_path_core(cmd, out_path, env_get_string(L"PATH")); } -bool path_get_cdpath_string(const wcstring &dir_str, wcstring &result, const env_var_t &cdpath) -{ - wchar_t *res = 0; - int err = ENOENT; - bool success = false; - - const wchar_t *const dir = dir_str.c_str(); - if (dir[0] == L'/'|| (wcsncmp(dir, L"./", 2)==0)) - { - struct stat buf; - if (wstat(dir, &buf) == 0) - { - if (S_ISDIR(buf.st_mode)) - { - result = dir_str; - success = true; - } - else - { - err = ENOTDIR; - } - - } - } - else - { - - wcstring path = L"."; - - // Respect CDPATH - env_var_t cdpath = env_get_string(L"CDPATH"); - if (! cdpath.missing_or_empty()) - { - path = cdpath.c_str(); - } - - wcstokenizer tokenizer(path, ARRAY_SEP_STR); - wcstring next_path; - while (tokenizer.next(next_path)) - { - expand_tilde(next_path); - if (next_path.size() == 0) continue; - - wcstring whole_path = next_path; - append_path_component(whole_path, dir); - - struct stat buf; - if (wstat(whole_path, &buf) == 0) - { - if (S_ISDIR(buf.st_mode)) - { - result = whole_path; - success = true; - break; - } - else - { - err = ENOTDIR; - } - } - else - { - if (lwstat(whole_path, &buf) == 0) - { - err = EROTTEN; - } - } - } - } - - - if (!success) - { - errno = err; - } - - return res; -} - bool path_get_cdpath(const wcstring &dir, wcstring *out, const wchar_t *wd, const env_vars_snapshot_t &env_vars) { int err = ENOENT; |