dots/.config/awesome/quarrel/fs.lua

30 lines
754 B
Lua

local GFile = require "lgi".Gio.File
local qfs = {}
function qfs.read(path, format)
local f = assert(io.open(path, "r"))
local c = f:read(format or "a")
f:close()
return c
end
function qfs.ls_files(path, absolute)
local files = GFile.new_for_path(path):enumerate_children("standard::*", 0)
local files_filtered = {}
if not files then return {} end
for file in function() return files:next_file() end do
if file:get_file_type() == "REGULAR" then
local file_name = file:get_display_name()
file_name = absolute and (path:gsub("[/]*$", "") .. "/" .. file_name) or file_name
table.insert(files_filtered, file_name)
end
end
return files_filtered
end
return qfs