From: Gordon Hecker Date: Tue, 5 Jan 2010 10:47:23 +0000 (+0100) Subject: bugfix: error checking in e2lib.write_file() X-Git-Tag: e2factory-2.3.4pre1~78 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=934759b04e62c4795f326cda0499bc1c6107192e;p=e2factory.git bugfix: error checking in e2lib.write_file() Signed-off-by: Gordon Hecker --- diff --git a/generic/e2lib.lua b/generic/e2lib.lua index ef67d10..48ac73a 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -1791,13 +1791,14 @@ end -- @return bool -- @return nil, or an error string function e2lib.write_file(file, data) - local f = io.open(file, "w") + local f, msg = io.open(file, "w") if not f then - return false, "open failed" + return false, string.format("open failed: %s", msg) end - local rc = f:write(data) + local rc, msg = f:write(data) if not rc then - return false, "write failed" + f:close() + return false, string.format("write failed: %s", msg) end f:close() return true, nil