Permalink
Browse files

Rewrite makepath() because mkdir() was since changed.

  • Loading branch information...
1 parent 1ebd04b commit f9ba9ebebcf758b030657e59ff61153e80a61196 @juster juster committed Apr 2, 2011
Showing with 11 additions and 19 deletions.
  1. +5 −2 clydelib/sync.lua
  2. +6 −17 clydelib/util.lua
View
@@ -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
View
@@ -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)

0 comments on commit f9ba9eb

Please sign in to comment.