shithub: mc

ref: 90dc5f51483723b1cd8604d749ef3158d55c21ca
dir: /lib/std/mkpath.myr/

View raw version
use "syswrap"
use "errno"

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

const mkpath = {p, mode
	var st

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

	-> Enone
}