summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-01-14 23:38:53 -0800
committerOri Bernstein <ori@eigenstate.org>2019-01-14 23:38:53 -0800
commit3dcee053786448f3479a929791cf6a474ae8c035 (patch)
tree534cf9cf5dddcd486c7e4ad16a46ab0f48a7c783
parentdb34187dc25f6b3f1a85b85c4dcf9a69b1cb4d54 (diff)
parent063145fc84acfe092a75d7bd2206987c147aa2b3 (diff)
downloadmc-3dcee053786448f3479a929791cf6a474ae8c035.tar.gz
Merge branch 'pathabs' of https://github.com/typeless/mc
-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][:]))
+ ;;
+}