From 8afdb3ee815d6fc81accba524e372cba5c72f4dd Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Wed, 15 Aug 2012 16:48:14 +0200 Subject: [PATCH] Use stat() in isdir(), invert logic in isfile() Signed-off-by: Tobias Ulmer --- generic/e2lib.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/generic/e2lib.lua b/generic/e2lib.lua index cd005a6..9cf2801 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -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 -- 2.39.5