Changeset 4887
- Timestamp:
- 06/21/09 14:41:18 (4 years ago)
- Location:
- luci/trunk/libs/nixio
- Files:
-
- 2 modified
-
lua/nixio/fs.lua (modified) (9 diffs)
-
src/fs.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/libs/nixio/lua/nixio/fs.lua
r4590 r4887 67 67 68 68 function copy(src, dest) 69 local stat, code, msg, res = nixio. lstat(src)69 local stat, code, msg, res = nixio.fs.lstat(src) 70 70 if not stat then 71 71 return nil, code, msg … … 73 73 74 74 if stat.type == "dir" then 75 if nixio. stat(dest, type) ~= "dir" then76 res, code, msg = nixio. mkdir(dest)75 if nixio.fs.stat(dest, type) ~= "dir" then 76 res, code, msg = nixio.fs.mkdir(dest) 77 77 else 78 78 stat = true 79 79 end 80 80 elseif stat.type == "lnk" then 81 res, code, msg = nixio. symlink(nixio.readlink(src), dest)81 res, code, msg = nixio.fs.symlink(nixio.fs.readlink(src), dest) 82 82 elseif stat.type == "reg" then 83 83 res, code, msg = datacopy(src, dest) … … 88 88 end 89 89 90 nixio. utimes(dest, stat.atime, stat.mtime)90 nixio.fs.utimes(dest, stat.atime, stat.mtime) 91 91 92 if nixio. lchown then93 nixio. lchown(dest, stat.uid, stat.gid)92 if nixio.fs.lchown then 93 nixio.fs.lchown(dest, stat.uid, stat.gid) 94 94 end 95 95 96 96 if stat.type ~= "lnk" then 97 nixio. chmod(dest, stat.modedec)97 nixio.fs.chmod(dest, stat.modedec) 98 98 end 99 99 … … 102 102 103 103 function move(src, dest) 104 local stat, code, msg = nixio. rename(src, dest)104 local stat, code, msg = nixio.fs.rename(src, dest) 105 105 if not stat and code == nixio.const.EXDEV then 106 stat, code, msg = nixio.copy(src, dest)106 stat, code, msg = copy(src, dest) 107 107 if stat then 108 stat, code, msg = nixio. unlink(src)108 stat, code, msg = nixio.fs.unlink(src) 109 109 end 110 110 end … … 113 113 114 114 function mkdirr(dest, mode) 115 if nixio. stat(dest, "type") == "dir" then115 if nixio.fs.stat(dest, "type") == "dir" then 116 116 return true 117 117 else 118 local stat, code, msg = nixio. mkdir(dest, mode)118 local stat, code, msg = nixio.fs.mkdir(dest, mode) 119 119 if not stat and code == nixio.const.ENOENT then 120 stat, code, msg = mkdirr(nixio. dirname(dest), mode)120 stat, code, msg = mkdirr(nixio.fs.dirname(dest), mode) 121 121 if stat then 122 stat, code, msg = nixio. mkdir(dest, mode)122 stat, code, msg = nixio.fs.mkdir(dest, mode) 123 123 end 124 124 end … … 128 128 129 129 local function _recurse(cb, src, dest) 130 local type = nixio. lstat(src, "type")130 local type = nixio.fs.lstat(src, "type") 131 131 if type ~= "dir" then 132 132 return cb(src, dest) … … 138 138 end 139 139 140 for e in nixio. dir(src) do140 for e in nixio.fs.dir(src) do 141 141 if dest then 142 142 s, c, m = _recurse(cb, src .. se .. e, dest .. se .. e) … … 161 161 162 162 function mover(src, dest) 163 local stat, code, msg = nixio. rename(src, dest)163 local stat, code, msg = nixio.fs.rename(src, dest) 164 164 if not stat and code == nixio.const.EXDEV then 165 165 stat, code, msg = _recurse(copy, src, dest) 166 166 if stat then 167 stat, code, msg = _recurse(nixio. remove, src)167 stat, code, msg = _recurse(nixio.fs.remove, src) 168 168 end 169 169 end … … 172 172 173 173 function remover(src) 174 return _recurse(nixio. remove, src)174 return _recurse(nixio.fs.remove, src) 175 175 end -
luci/trunk/libs/nixio/src/fs.c
r4437 r4887 255 255 static int nixio_utimes(lua_State *L) { 256 256 const char *path = luaL_checkstring(L, 1); 257 if (lua_gettop(L) < 2 ) {257 if (lua_gettop(L) < 2 || (lua_isnoneornil(L, 2) && lua_isnoneornil(L, 3))) { 258 258 return nixio__pstatus(L, !utimes(path, NULL)); 259 259 } else {
