aboutsummaryrefslogtreecommitdiff
path: root/src/path.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-09-01 06:35:52 +0000
committer_ov4 <ov4@ov4.org>2026-09-01 06:35:52 +0000
commitc1733952f1bbb567b335109f51fb66a73abfedd3 (patch)
treed299d08a55d146e5c8cc21f5e68b689e15bdff08 /src/path.cc
parentc9c3b2f4357e30dd078075b3259d86adca6958e3 (diff)
path .
Diffstat (limited to 'src/path.cc')
-rw-r--r--src/path.cc24
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;
+}
+
}