History

Add pathabs

Mura Li committed 7 years ago

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

Unified · Split

lib/std/pathjoin.myr+10−0
@@ -2,6 +2,8 @@ use "alloc" · 1 unmodified line
2use "die"2use "die"
3use "extremum"3use "extremum"
4use "fmt"4use "fmt"
5use "hasprefix"
6use "getcwd"
5use "sleq"7use "sleq"
6use "slcp"8use "slcp"
7use "sldup"9use "sldup"
@@ -14,6 +16,7 @@ pkg std = · 6 unmodified lines
14 const pathcat : (a : byte[:], b : byte[:] -> byte[:])16 const pathcat : (a : byte[:], b : byte[:] -> byte[:])
15 const pathjoin : (p : byte[:][:] -> byte[:])17 const pathjoin : (p : byte[:][:] -> byte[:])
16 const pathnorm : (p : byte[:] -> byte[:])18 const pathnorm : (p : byte[:] -> byte[:])
19 const pathabs : (p : byte[:] -> byte[:])
17;;20;;
18 21
19const pathcat = {a, b22const pathcat = {a, b
@@ -104,3 +107,10 @@ const pathnorm = {p · 84 unmodified lines
104 -> ret107 -> ret
105}108}
106 109
110const 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