]> git.e2factory.org Git - e2factory.git/commitdiff
Use stat() in isdir(), invert logic in isfile()
authorTobias Ulmer <tu@emlix.com>
Wed, 15 Aug 2012 14:48:14 +0000 (16:48 +0200)
committerTobias Ulmer <tu@emlix.com>
Tue, 26 Feb 2013 18:07:06 +0000 (19:07 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/e2lib.lua

index cd005a6ea6a534123811d9c44f496fa232b7ac4b..9cf2801cf75c04ab6108a386b241bf8e3a141fbf 100644 (file)
@@ -1730,8 +1730,12 @@ end
 -- @param dir string: path
 -- @return bool
 function e2lib.isdir(dir)
-    local args = string.format("-d '%s'", dir)
-    return e2lib.call_tool("test", args)
+    local t = e2util.stat(dir, true)
+    if t and t.type == "directory" then
+        return true
+    end
+
+    return false
 end
 
 --- check if path is a file
@@ -1739,10 +1743,10 @@ end
 -- @return bool
 function e2lib.isfile(path)
     local t = e2util.stat(path, true)
-    if not t or t.type ~= "regular" then
-        return false
+    if t and t.type == "regular" then
+        return true
     end
-    return true
+    return false
 end
 
 --- calculate SHA1 sum for a file