mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
Close files explicitly when done
Even though files are automatically closed, per the manual it takes "an unpredictable amount of time to happen".
This commit is contained in:
parent
8c2be55dbb
commit
3320932c71
@ -49,6 +49,7 @@ moon_loader = function(name)
|
||||
end
|
||||
if file then
|
||||
local text = file:read("*a")
|
||||
file:close()
|
||||
return loadstring(text, file_path)
|
||||
else
|
||||
return nil, "Could not find moon file"
|
||||
@ -82,6 +83,7 @@ loadfile = function(fname)
|
||||
return nil, err
|
||||
end
|
||||
local text = assert(file:read("*a"))
|
||||
file:close()
|
||||
return loadstring(text, fname)
|
||||
end
|
||||
dofile = function(fname)
|
||||
|
@ -50,6 +50,7 @@ moon_loader = (name) ->
|
||||
|
||||
if file
|
||||
text = file\read "*a"
|
||||
file\close!
|
||||
loadstring text, file_path
|
||||
else
|
||||
nil, "Could not find moon file"
|
||||
@ -74,6 +75,7 @@ loadfile = (fname) ->
|
||||
file, err = io.open fname
|
||||
return nil, err if not file
|
||||
text = assert file\read "*a"
|
||||
file\close!
|
||||
loadstring text, fname
|
||||
|
||||
-- throws errros
|
||||
|
Loading…
Reference in New Issue
Block a user