History

Add pathabs

Mura Li committed 7 years ago

Commit 9541bb71 parent f3551bc1 file · +10 −0Browse files

Showing the changes to lib/std (1 of 1 file). Show all

Unified · Split

lib/std/pathjoin.myr+10−0
@@ -2,6 +2,8 @@ use "alloc" · 1 unmodified line
22 use "die"
33 use "extremum"
44 use "fmt"
5+use "hasprefix"
6+use "getcwd"
57 use "sleq"
68 use "slcp"
79 use "sldup"
@@ -14,6 +16,7 @@ pkg std = · 6 unmodified lines
1416 const pathcat : (a : byte[:], b : byte[:] -> byte[:])
1517 const pathjoin : (p : byte[:][:] -> byte[:])
1618 const pathnorm : (p : byte[:] -> byte[:])
19+ const pathabs : (p : byte[:] -> byte[:])
1720 ;;
1821
1922 const pathcat = {a, b
@@ -104,3 +107,10 @@ const pathnorm = {p · 84 unmodified lines
104107 -> ret
105108 }
106109
110+const pathabs = {p
111+ if hasprefix(p, "/")
112+ -> pathnorm(p)
113+ else
114+ -> pathnorm(pathjoin([getcwd(), p][:]))
115+ ;;
116+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t