ref: 063145fc84acfe092a75d7bd2206987c147aa2b3
parent: 330b2e6a59402d3a290629f409d77c2692973f3c
author: Mura Li <[email protected]>
date: Fri Jan 4 19:23:46 EST 2019
Add pathabs
--- a/lib/std/pathjoin.myr
+++ b/lib/std/pathjoin.myr
@@ -2,6 +2,8 @@
use "die"
use "extremum"
use "fmt"
+use "hasprefix"
+use "getcwd"
use "sleq"
use "slcp"
use "sldup"
@@ -14,6 +16,7 @@
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 @@
-> ret
}
+const pathabs = {p
+ if hasprefix(p, "/")
+ -> pathnorm(p)
+ else
+ -> pathnorm(pathjoin([getcwd(), p][:]))
+ ;;
+}