Add function to check file executable bit

This is just a plain copy of the file_readable function, with "read"
replaced with "execute".
This commit is contained in:
Florian Gamböck 2017-07-02 15:55:19 +02:00
parent 0def266c84
commit a68cc783c9
1 changed files with 11 additions and 0 deletions

View File

@ -53,6 +53,17 @@ function filesystem.file_readable(filename)
gfileinfo:get_attribute_boolean("access::can-read") gfileinfo:get_attribute_boolean("access::can-read")
end end
--- Check if a file exists, is executable and not a directory.
-- @tparam string filename The file path.
-- @treturn boolean True if file exists and is executable.
function filesystem.file_executable(filename)
local gfile = Gio.File.new_for_path(filename)
local gfileinfo = gfile:query_info("standard::type,access::can-execute",
Gio.FileQueryInfoFlags.NONE)
return gfileinfo and gfileinfo:get_file_type() ~= "DIRECTORY" and
gfileinfo:get_attribute_boolean("access::can-execute")
end
--- Check if a path exists, is readable and a directory. --- Check if a path exists, is readable and a directory.
-- @tparam string path The directory path. -- @tparam string path The directory path.
-- @treturn boolean True if path exists and is readable. -- @treturn boolean True if path exists and is readable.