X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fuvl%2Fluasrc%2Fuvl%2Fdatatypes.lua;h=c6a5de39888af222035996eea21f32e4c04bb2cc;hp=fc37fa3c6989dfa378760f4f8fc225aa4e7bc9fb;hb=8fcd841aa9af96c8a4a4d3c1a555d2d1ed42332c;hpb=77432eb0479ec101aaa2287394ec8751d589aed2 diff --git a/libs/uvl/luasrc/uvl/datatypes.lua b/libs/uvl/luasrc/uvl/datatypes.lua index fc37fa3c6..c6a5de398 100644 --- a/libs/uvl/luasrc/uvl/datatypes.lua +++ b/libs/uvl/luasrc/uvl/datatypes.lua @@ -14,7 +14,7 @@ $Id$ ]]-- -local fs = require "luci.fs" +local fs = require "nixio.fs" local ip = require "luci.ip" local math = require "math" local util = require "luci.util" @@ -144,9 +144,9 @@ function directory( val, seen ) if s and not seen[s.ino] then seen[s.ino] = true - if s.type == "directory" then + if s.type == "dir" then return true - elseif s.type == "link" then + elseif s.type == "lnk" then return directory( fs.readlink(val), seen ) end end @@ -160,12 +160,28 @@ function file( val, seen ) if s and not seen[s.ino] then seen[s.ino] = true - if s.type == "regular" then + if s.type == "reg" then return true - elseif s.type == "link" then + elseif s.type == "lnk" then return file( fs.readlink(val), seen ) end end return false end + +function device( val, seen ) + local s = fs.stat( val ) + seen = seen or { } + + if s and not seen[s.ino] then + seen[s.ino] = true + if s.type == "chr" or s.type == "blk" then + return true + elseif s.type == "lnk" then + return device( fs.readlink(val), seen ) + end + end + + return false +end