From b3530d7c4a102935fa26498a160ee1dc6c1e9c03 Mon Sep 17 00:00:00 2001 From: delta Date: Fri, 4 Jul 2025 00:38:29 +0200 Subject: :3 --- .config/awesome/quarrel/fs.lua | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to '.config/awesome/quarrel/fs.lua') 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 -- cgit v1.2.3