shithub: mc

Download patch

ref: 3dcee053786448f3479a929791cf6a474ae8c035
parent: db34187dc25f6b3f1a85b85c4dcf9a69b1cb4d54
parent: 063145fc84acfe092a75d7bd2206987c147aa2b3
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Jan 14 18:38:53 EST 2019

Merge branch 'pathabs' of https://github.com/typeless/mc

--- a/lib/std/pathjoin.myr
+++ b/lib/std/pathjoin.myr
@@ -2,6 +2,8 @@
 use "die"
 use "extremum"
 use "fmt"
+use "hasprefix"
+use "getcwd"
 use "sleq"
 use "slcp"
 use "sldup"
@@ -14,6 +16,7 @@
 	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
@@ -104,3 +107,10 @@
 	-> ret
 }
 
+const pathabs = {p
+	if hasprefix(p, "/")
+		-> pathnorm(p)
+	else
+		-> pathnorm(pathjoin([getcwd(), p][:]))
+	;;
+}