diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2024-03-20 12:30:08 -0400 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2024-03-20 12:30:08 -0400 |
commit | fd97818a70652471b33b577e2d8ea855e770d533 (patch) | |
tree | 82338d5a430d299c193f631e9094ac4d938768e8 /src | |
parent | 57a17aeff26711a44a214cb0e3c2dc72c84d8e8f (diff) | |
download | lite-xl-plugin-manager-fd97818a70652471b33b577e2d8ea855e770d533.tar.gz lite-xl-plugin-manager-fd97818a70652471b33b577e2d8ea855e770d533.zip |
Ensures that we close read handles on files.
Diffstat (limited to 'src')
-rw-r--r-- | src/lpm.lua | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lpm.lua b/src/lpm.lua index 16f178a..cb95b1a 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -393,7 +393,7 @@ function common.slice(t, i, l) local n = {} for j = i, l ~= nil and (i - l) or # function common.join(j, l) local s = "" for i, v in ipairs(l) do if i > 1 then s = s .. j .. v else s = v end end return s end function common.sort(t, f) table.sort(t, f) return t end function common.write(path, contents) local f, err = io.open(path, "wb") if not f then error("can't write to " .. path .. ": " .. err) end f:write(contents) f:flush() f:close() end -function common.read(path) local f, err = io.open(path, "rb") if not f then error("can't read from " .. path .. ": " .. err) end return f:read("*all") end +function common.read(path) local f, err = io.open(path, "rb") if not f then error("can't read from " .. path .. ": " .. err) end local str = f:read("*all") f:close() return str end function common.uniq(l) local t = {} local k = {} for i,v in ipairs(l) do if not k[v] then table.insert(t, v) k[v] = true end end return t end function common.delete(h, d) local t = {} for k,v in pairs(h) do if k ~= d then t[k] = v end end return t end function common.canonical_order(hash) local t = {} for k,v in pairs(hash) do table.insert(t, k) end table.sort(t) return t end |