shithub: mc

ref: 545d75324d8ad1d9f8f9977b0911e8e9e0704674
dir: /lib/std/mkpath.myr/

View raw version
use "syswrap"
use "errno"

pkg std =
	const mkpath	: (p : byte[:] -> errno)
;;

const mkpath = {p
	var st

	for var i = 0; i < p.len; i++
		if p[i] == ('/' : byte) && i != 0
			st = mkdir(p[:i], 0o755)
			if st != 0 && st != Eexist
				-> st
			;;
		;;
	;;
	st = mkdir(p, 0o755)

	-> Enone
}