Showing the changes to lib/std (1 of 1 file). Show all
Unified · Split
| @@ -2,6 +2,8 @@ use "alloc" · 1 unmodified line | ||
| 2 | 2 | use "die" |
| 3 | 3 | use "extremum" |
| 4 | 4 | use "fmt" |
| 5 | +use "hasprefix" | |
| 6 | +use "getcwd" | |
| 5 | 7 | use "sleq" |
| 6 | 8 | use "slcp" |
| 7 | 9 | use "sldup" |
| @@ -14,6 +16,7 @@ pkg std = · 6 unmodified lines | ||
| 14 | 16 | const pathcat : (a : byte[:], b : byte[:] -> byte[:]) |
| 15 | 17 | const pathjoin : (p : byte[:][:] -> byte[:]) |
| 16 | 18 | const pathnorm : (p : byte[:] -> byte[:]) |
| 19 | + const pathabs : (p : byte[:] -> byte[:]) | |
| 17 | 20 | ;; |
| 18 | 21 | |
| 19 | 22 | const pathcat = {a, b |
| @@ -104,3 +107,10 @@ const pathnorm = {p · 84 unmodified lines | ||
| 104 | 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 | +} | |