Showing the changes to lib/std (1 of 1 file). Show all
Unified · Split
| @@ -2,6 +2,8 @@ use "alloc" · 1 unmodified line | |||
| 2 | use "die" | 2 | use "die" |
| 3 | use "extremum" | 3 | use "extremum" |
| 4 | use "fmt" | 4 | use "fmt" |
| 5 | use "hasprefix" | ||
| 6 | use "getcwd" | ||
| 5 | use "sleq" | 7 | use "sleq" |
| 6 | use "slcp" | 8 | use "slcp" |
| 7 | use "sldup" | 9 | use "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 | ||
| 19 | const pathcat = {a, b | 22 | const pathcat = {a, b |
| @@ -104,3 +107,10 @@ const pathnorm = {p · 84 unmodified lines | |||
| 104 | -> ret | 107 | -> ret |
| 105 | } | 108 | } |
| 106 | 109 | ||
| 110 | const pathabs = {p | ||
| 111 | if hasprefix(p, "/") | ||
| 112 | -> pathnorm(p) | ||
| 113 | else | ||
| 114 | -> pathnorm(pathjoin([getcwd(), p][:])) | ||
| 115 | ;; | ||
| 116 | } | ||