From c1733952f1bbb567b335109f51fb66a73abfedd3 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 1 Sep 2026 06:35:52 +0000 Subject: path . --- src/path.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/path.cc') 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; +} + } -- cgit v1.3.1-4-g156e