Changeset 4887

Show
Ignore:
Timestamp:
06/21/09 14:41:18 (4 years ago)
Author:
Cyrus
Message:

nixio: Resolve namespace clashes

Location:
luci/trunk/libs/nixio
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/nixio/lua/nixio/fs.lua

    r4590 r4887  
    6767 
    6868function copy(src, dest) 
    69     local stat, code, msg, res = nixio.lstat(src) 
     69    local stat, code, msg, res = nixio.fs.lstat(src) 
    7070    if not stat then 
    7171        return nil, code, msg 
     
    7373     
    7474    if stat.type == "dir" then 
    75         if nixio.stat(dest, type) ~= "dir" then 
    76             res, code, msg = nixio.mkdir(dest) 
     75        if nixio.fs.stat(dest, type) ~= "dir" then 
     76            res, code, msg = nixio.fs.mkdir(dest) 
    7777        else 
    7878            stat = true 
    7979        end 
    8080    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) 
    8282    elseif stat.type == "reg" then 
    8383        res, code, msg = datacopy(src, dest) 
     
    8888    end 
    8989     
    90     nixio.utimes(dest, stat.atime, stat.mtime) 
     90    nixio.fs.utimes(dest, stat.atime, stat.mtime) 
    9191     
    92     if nixio.lchown then 
    93         nixio.lchown(dest, stat.uid, stat.gid) 
     92    if nixio.fs.lchown then 
     93        nixio.fs.lchown(dest, stat.uid, stat.gid) 
    9494    end 
    9595     
    9696    if stat.type ~= "lnk" then 
    97         nixio.chmod(dest, stat.modedec) 
     97        nixio.fs.chmod(dest, stat.modedec) 
    9898    end 
    9999     
     
    102102 
    103103function move(src, dest) 
    104     local stat, code, msg = nixio.rename(src, dest) 
     104    local stat, code, msg = nixio.fs.rename(src, dest) 
    105105    if not stat and code == nixio.const.EXDEV then 
    106         stat, code, msg = nixio.copy(src, dest) 
     106        stat, code, msg = copy(src, dest) 
    107107        if stat then 
    108             stat, code, msg = nixio.unlink(src) 
     108            stat, code, msg = nixio.fs.unlink(src) 
    109109        end 
    110110    end 
     
    113113 
    114114function mkdirr(dest, mode) 
    115     if nixio.stat(dest, "type") == "dir" then 
     115    if nixio.fs.stat(dest, "type") == "dir" then 
    116116        return true 
    117117    else 
    118         local stat, code, msg = nixio.mkdir(dest, mode) 
     118        local stat, code, msg = nixio.fs.mkdir(dest, mode) 
    119119        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) 
    121121            if stat then 
    122                 stat, code, msg = nixio.mkdir(dest, mode) 
     122                stat, code, msg = nixio.fs.mkdir(dest, mode) 
    123123            end 
    124124        end 
     
    128128 
    129129local function _recurse(cb, src, dest) 
    130     local type = nixio.lstat(src, "type") 
     130    local type = nixio.fs.lstat(src, "type") 
    131131    if type ~= "dir" then 
    132132        return cb(src, dest) 
     
    138138        end 
    139139 
    140         for e in nixio.dir(src) do 
     140        for e in nixio.fs.dir(src) do 
    141141            if dest then 
    142142                s, c, m = _recurse(cb, src .. se .. e, dest .. se .. e) 
     
    161161 
    162162function mover(src, dest) 
    163     local stat, code, msg = nixio.rename(src, dest) 
     163    local stat, code, msg = nixio.fs.rename(src, dest) 
    164164    if not stat and code == nixio.const.EXDEV then 
    165165        stat, code, msg = _recurse(copy, src, dest) 
    166166        if stat then 
    167             stat, code, msg = _recurse(nixio.remove, src) 
     167            stat, code, msg = _recurse(nixio.fs.remove, src) 
    168168        end 
    169169    end 
     
    172172 
    173173function remover(src) 
    174     return _recurse(nixio.remove, src) 
     174    return _recurse(nixio.fs.remove, src) 
    175175end 
  • luci/trunk/libs/nixio/src/fs.c

    r4437 r4887  
    255255static int nixio_utimes(lua_State *L) { 
    256256    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))) { 
    258258        return nixio__pstatus(L, !utimes(path, NULL)); 
    259259    } else {