diff options
Diffstat (limited to 'src/path.cc')
| -rw-r--r-- | src/path.cc | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/path.cc b/src/path.cc index 620c464..e9d1892 100644 --- a/src/path.cc +++ b/src/path.cc @@ -5,6 +5,8 @@ namespace ov4 using namespace std; +string current_dir; + string find_cmd(char* s) { string tmp = s; @@ -13,8 +15,11 @@ string find_cmd(char* s) string find_cmd(string s) { - if (s.size() == 0) return "/"; - if (s[0] == '/') return s; + if (s.size() == 0) return ""; + string unified_s = path_unifier(s); + cout << unified_s << endl; + if (access(unified_s.c_str(), F_OK) == 0) + return unified_s; string path = getenv("PATH"); size_t i = 0, j = 0, l = path.size(); @@ -37,5 +42,20 @@ string find_cmd(string s) } } +string path_unifier(const string &s) +{ + if (s.size() == 0) return ""; + if (s[0] == '/') return s; + if (s[0] == '.') + { + return current_dir + s.substr(1); + } +} + +string set_current_dir(string s) +{ + return current_dir = s; +} + } |
