1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-18 09:17:40 +00:00
This commit is contained in:
kepler155c@gmail.com
2019-03-12 20:04:28 -04:00
parent 86be65f026
commit e2508c9037
5 changed files with 20 additions and 0 deletions

View File

@@ -414,6 +414,16 @@ end
function Util.writeFile(fname, data)
if not fname or not data then error('Util.writeFile: invalid parameters', 2) end
if fs.exists(fname) then
local diff = #data - fs.getSize(fname)
if diff > 0 then
if fs.getFreeSpace(fs.getDir(fname)) < diff then
error('Insufficient disk space for ' .. fname)
end
end
end
local file = io.open(fname, "w")
if not file then
error('Unable to open ' .. fname, 2)