aboutsummaryrefslogtreecommitdiff
path: root/src/path.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-09-01 07:58:49 +0000
committer_ov4 <ov4@ov4.org>2026-09-01 07:58:49 +0000
commit9a09c0bfc5956ed57fa4c26f84babb6778fa8a34 (patch)
tree9f11e72fa682dbaad744a4b617500d924e8436e4 /src/path.cc
parentc1733952f1bbb567b335109f51fb66a73abfedd3 (diff)
path
Diffstat (limited to 'src/path.cc')
-rw-r--r--src/path.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/path.cc b/src/path.cc
index e9d1892..4d2ea1b 100644
--- a/src/path.cc
+++ b/src/path.cc
@@ -5,19 +5,16 @@ namespace ov4
using namespace std;
-string current_dir;
-
-string find_cmd(char* s)
+string find_cmd(const char * s)
{
- string tmp = s;
+ const string tmp = s;
return find_cmd(tmp);
}
-string find_cmd(string s)
+string find_cmd(const string &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;
@@ -48,13 +45,18 @@ string path_unifier(const string &s)
if (s[0] == '/') return s;
if (s[0] == '.')
{
- return current_dir + s.substr(1);
+ return get_current_dir() + s.substr(1);
}
}
-string set_current_dir(string s)
+int set_current_dir(const string &s)
+{
+ return chdir(s.c_str());
+}
+
+string get_current_dir()
{
- return current_dir = s;
+ return (string)(get_current_dir_name());
}