awful.util: new function file_readable()

Signed-off-by: koniu <gkusnierz@gmail.com>
This commit is contained in:
koniu 2008-11-22 16:23:03 +00:00 committed by Julien Danjou
parent 0358d1085d
commit 92fd31b7f5
1 changed files with 13 additions and 0 deletions

View File

@ -156,4 +156,17 @@ function getdir(d)
return os.getenv("HOME").."/.cache/awesome" return os.getenv("HOME").."/.cache/awesome"
end end
end end
--- Check if file exists and is readable.
-- @param filename The file path
-- @return True if file exists and readable.
function file_readable(filename)
local file = io.open(filename)
if file then
io.close(file)
return true
end
return false
end
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80