From 92fd31b7f589a39d439acfed4227190d96c7f265 Mon Sep 17 00:00:00 2001 From: koniu Date: Sat, 22 Nov 2008 16:23:03 +0000 Subject: [PATCH] awful.util: new function file_readable() Signed-off-by: koniu --- lib/awful/util.lua.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/awful/util.lua.in b/lib/awful/util.lua.in index 5cb5e709b..d72ff413a 100644 --- a/lib/awful/util.lua.in +++ b/lib/awful/util.lua.in @@ -156,4 +156,17 @@ function getdir(d) return os.getenv("HOME").."/.cache/awesome" 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