Skip to content

Commit

Permalink
Rewrite makepath() because mkdir() was since changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
juster committed Apr 2, 2011
1 parent 1ebd04b commit f9ba9eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
7 changes: 5 additions & 2 deletions clydelib/sync.lua
Expand Up @@ -196,8 +196,11 @@ local function sync_cleancache(level)
return 1
end

if (makepath(cachedir)) then
eprintf("LOG_ERROR", g("could not create new cache directory\n"))
local success, err = pcall( makepath, cachedir )
if not success then
eprintf("LOG_ERROR", "%smkdir: %s\n",
g("could not create new cache directory\n"),
err )
return 1
end
end
Expand Down
23 changes: 6 additions & 17 deletions clydelib/util.lua
Expand Up @@ -330,25 +330,14 @@ function rmrf(path)
end
end

function makepath(path)
local oldmask = utilcore.umask("0000")
local ret = false
local parts = strsplit(path:sub(2, #path-1), "/")
local incr = ""

for i, part in ipairs(parts) do
incr = incr .. "/" .. part
if (utilcore.access(incr, "F_OK") ~= 0) then
if (utilcore.mkdir(incr,"755") ~= 0) then
ret = true
break
end
function makepath ( destpath )
local path = ""
for comp in destpath:gmatch( "([^/]+)" ) do
path = path .. "/" .. comp
if utilcore.access( path, "F_OK" ) ~= 0 then
utilcore.mkdir( path, "0755" )
end
end

utilcore.umask(oldmask)

return ret
end

function indentprint(str, indent, space)
Expand Down

0 comments on commit f9ba9eb

Please sign in to comment.