Skip to content

Commit

Permalink
Add pathabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mura Li committed Jan 4, 2019
1 parent 330b2e6 commit 063145f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/std/pathjoin.myr
Expand Up @@ -2,6 +2,8 @@ use "alloc"
use "die"
use "extremum"
use "fmt"
use "hasprefix"
use "getcwd"
use "sleq"
use "slcp"
use "sldup"
Expand All @@ -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
Expand Down Expand Up @@ -104,3 +107,10 @@ const pathnorm = {p
-> ret
}

const pathabs = {p
if hasprefix(p, "/")
-> pathnorm(p)
else
-> pathnorm(pathjoin([getcwd(), p][:]))
;;
}

0 comments on commit 063145f

Please sign in to comment.