From a0e7f88b00fc2feba904478d16821c26940f6b84 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 9 Feb 2015 20:17:40 +0100 Subject: [PATCH] awful.util.file_readable: return false for dirs This is currently only used for icon lookups / where files are expected. --- lib/awful/util.lua.in | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/awful/util.lua.in b/lib/awful/util.lua.in index d9709b795..d62971956 100644 --- a/lib/awful/util.lua.in +++ b/lib/awful/util.lua.in @@ -207,13 +207,18 @@ function util.geticonpath(iconname, exts, dirs, size) end end ---- Check if file exists and is readable. --- @param filename The file path --- @return True if file exists and readable. +--- Check if a file exists, is not readable and not a directory. +-- @param filename The file path. +-- @return True if file exists and is readable. function util.file_readable(filename) local file = io.open(filename) if file then + local _, _, code = file:read(1) io.close(file) + if code == 21 then + -- "Is a directory". + return false + end return true end return false