diff options
author | delta <darkussdelta@gmail.com> | 2023-04-04 15:43:40 +0200 |
---|---|---|
committer | delta <darkussdelta@gmail.com> | 2023-04-04 15:43:40 +0200 |
commit | f7116d268aff3fae88d8de408e8c807295618a5c (patch) | |
tree | 6f52530d5799769e6af7c63bc5108f16f9aff742 /.config/awesome/quarrel/fs.lua | |
parent | f0b32f45746c026d402651013b7e98315d6956a1 (diff) |
restructure and improve config
Diffstat (limited to '.config/awesome/quarrel/fs.lua')
-rw-r--r-- | .config/awesome/quarrel/fs.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/.config/awesome/quarrel/fs.lua b/.config/awesome/quarrel/fs.lua new file mode 100644 index 0000000..89a1bc6 --- /dev/null +++ b/.config/awesome/quarrel/fs.lua @@ -0,0 +1,29 @@ +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 |