mirror of
https://github.com/kepler155c/opus
synced 2025-10-18 09:17:40 +00:00
cleanup
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user