aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/quarrel/fs.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/awesome/quarrel/fs.lua')
-rw-r--r--.config/awesome/quarrel/fs.lua21
1 files changed, 16 insertions, 5 deletions
diff --git a/.config/awesome/quarrel/fs.lua b/.config/awesome/quarrel/fs.lua
index 502f189..fa3fc21 100644
--- a/.config/awesome/quarrel/fs.lua
+++ b/.config/awesome/quarrel/fs.lua
@@ -1,24 +1,35 @@
+local gdebug = require "gears.debug"
local GFile = require("lgi").Gio.File
---@class QuarrelFs
-local qfs = {}
+local M = {}
--- Read a file with the specified format (or "a") and close the file
---@param path string
----@param format openmode
+---@param format? openmode
---@return any
-function qfs.read(path, format)
+function M.read(path, format)
local f = assert(io.open(path, "r"))
local c = f:read(format or "a")
f:close()
return c
end
+--- Write a file with the specified format (or "a") and close the file
+---@param path string
+---@param format? openmode
+---@return any
+function M.write(content, path, format)
+ local f = assert(io.open(path, format or "w+"))
+ f:write(content)
+ f:close()
+end
+
--- List files in a directory
---@param path string
---@param absolute boolean?
---@return table
-function qfs.ls_files(path, absolute)
+function M.ls_files(path, absolute)
local files = GFile.new_for_path(path):enumerate_children("standard::*", 0)
local files_filtered = {}
@@ -41,4 +52,4 @@ function qfs.ls_files(path, absolute)
return files_filtered
end
-return qfs
+return M