fixed io.type

This commit is contained in:
Florian Nücke 2013-10-06 15:10:28 +02:00
parent 9886e646de
commit a73ed001dd

View File

@ -220,7 +220,7 @@ local file = {}
function file:close() function file:close()
if self.handle then if self.handle then
self:flush() self:flush()
self.stream:close() return self.stream:close()
end end
end end
@ -503,7 +503,7 @@ function file.new(fs, handle, mode, stream, nogc)
local metatable = { local metatable = {
__index = file, __index = file,
__metatable = "private" __metatable = "file"
} }
if not nogc then if not nogc then
metatable.__gc = function(self) metatable.__gc = function(self)
@ -561,9 +561,8 @@ end
function driver.fs.type(object) function driver.fs.type(object)
if type(object) == "table" then if type(object) == "table" then
local mt = getmetatable(object) if getmetatable(object) == "file" then
if mt and mt.__index == file then if object.handle then
if f.handle then
return "file" return "file"
else else
return "closed file" return "closed file"