From 14f7d20d0f5cd4b0986d2f0485f332b28b620661 Mon Sep 17 00:00:00 2001 From: actionless Date: Wed, 27 Apr 2016 18:28:12 +0200 Subject: [PATCH] refactor(awful: util): use lgi.Gio for is_dir --- lib/awful/util.lua | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/awful/util.lua b/lib/awful/util.lua index b1ad65045..c64c43e25 100644 --- a/lib/awful/util.lua +++ b/lib/awful/util.lua @@ -253,16 +253,7 @@ end -- @tparam string path -- @treturn bool True if path exists and is a directory. function util.is_dir(path) - local file = io.open(path) - if file then - if not file:read(0) -- Not a regular file (might include empty ones). - and file:seek("end") ~= 0 then -- And not a file with size 0. - io.close(file) - return true - end - io.close(file) - end - return false + return Gio.File.new_for_path(path):query_file_type({}) == "DIRECTORY" end local function subset_mask_apply(mask, set)