build: remove some obsolete support scripts
[project/luci.git] / libs / uvl / luasrc / uvl / datatypes.lua
index 971bb9d..c6a5de3 100644 (file)
@@ -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"
@@ -29,6 +29,8 @@ function boolean( val )
                return true
        elseif val == "0" or val == "no" or val == "off" or val == "false" then
                return true
+       elseif val == "" or val == nil then
+               return true
        end
 
        return false
@@ -142,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
@@ -158,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