summaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorMura Li <mura_li@example.com>2019-01-05 00:23:46 +0800
committerMura Li <mura_li@example.com>2019-01-05 00:36:57 +0800
commit063145fc84acfe092a75d7bd2206987c147aa2b3 (patch)
tree2dbf665ea53fa10fc5effbac36fff520b4e6f145 /lib/std
parent330b2e6a59402d3a290629f409d77c2692973f3c (diff)
downloadmc-063145fc84acfe092a75d7bd2206987c147aa2b3.tar.gz
Add pathabs
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/pathjoin.myr10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/std/pathjoin.myr b/lib/std/pathjoin.myr
index 17d8a9f..18f2414 100644
--- a/lib/std/pathjoin.myr
+++ b/lib/std/pathjoin.myr
@@ -2,6 +2,8 @@ use "alloc"
use "die"
use "extremum"
use "fmt"
+use "hasprefix"
+use "getcwd"
use "sleq"
use "slcp"
use "sldup"
@@ -14,6 +16,7 @@ pkg std =
const pathcat : (a : byte[:], b : byte[:] -> byte[:])
const pathjoin : (p : byte[:][:] -> byte[:])
const pathnorm : (p : byte[:] -> byte[:])
+ const pathabs : (p : byte[:] -> byte[:])
;;
const pathcat = {a, b
@@ -104,3 +107,10 @@ const pathnorm = {p
-> ret
}
+const pathabs = {p
+ if hasprefix(p, "/")
+ -> pathnorm(p)
+ else
+ -> pathnorm(pathjoin([getcwd(), p][:]))
+ ;;
+}