From 3320932c717f1c158f8d4db645ec7e090964e928 Mon Sep 17 00:00:00 2001 From: Nils Nordman Date: Fri, 27 Apr 2012 20:36:39 +0200 Subject: [PATCH] Close files explicitly when done Even though files are automatically closed, per the manual it takes "an unpredictable amount of time to happen". --- moonscript/init.lua | 2 ++ moonscript/init.moon | 2 ++ 2 files changed, 4 insertions(+) diff --git a/moonscript/init.lua b/moonscript/init.lua index 3e05de5..51a1e04 100644 --- a/moonscript/init.lua +++ b/moonscript/init.lua @@ -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) diff --git a/moonscript/init.moon b/moonscript/init.moon index 2fb95e8..b059387 100644 --- a/moonscript/init.moon +++ b/moonscript/init.moon @@ -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