Re: Status of lposix?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Status of lposix?
 
- From: Wesley Smith <wesley.hoke@...>
 
- Date: 2009年5月28日 01:34:54 -0700
 
> * lfs.mkdir() only creates the directory if all parent directories are
> created first.  I prefer a directory creation function I call to do
> everything needed to fully create the directory I ask for.
based on your email, this is probably too heavyweight for you, but nonetheless:
function pathchunks(name)
	local chunks = {}
	for w in string.gmatch(name, "[^/\\]+") do
	 table.insert(chunks, 1, w)
	end
	return chunks
end
function ensurepath(path)
	local chunks = pathchunks(path)
	local originalpath = lfs.currentdir()
	lfs.chdir("/")
	for i=#chunks, 1, -1 do
		local c = chunks[i]
		local exists = lfs.attributes(c) ~= nil
		if(not exists) then
			lfs.mkdir(c)
		end
		lfs.chdir(c)
	end
	lfs.chdir(originalpath)
end
Does the job for me...
wes
- References:
- Status of lposix?, steve donovan
 
- Re: Status of lposix?, David Burgess
 
- Re: Status of lposix?, David Burgess
 
- Re: Status of lposix?, RJP Computing
 
- Re: Status of lposix?, David Burgess
 
- Re: Status of lposix?, Joshua Jensen
 
- Re: Status of lposix?, David Burgess
 
- Re: Status of lposix?, Joshua Jensen
 
- Re: Status of lposix?, steve donovan
 
- Re: Status of lposix?, Joshua Jensen