lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Sorry for the double post. I forgot to remove the triple ___ in some places, remove those before trying the code.

On Tue, Oct 23, 2012 at 12:41 PM, Konstantinos Asimakis <inshame@gmail.com> wrote:
--This goes somewhere very early in your code, before opening any file.
do
    local files={}
    local oldopen=io.open
    function io.open(f,m) 
        local r=oldopen(f,m)
        ___files[r]=m
        return r
    end
    function io.getmode(handle)
        return ___files[handle]
    end
end


t=io.open("/dev/random","r")
--This will print "r".
print(io.getmode(t))
--And probably this would also work but I haven't tested it: t:getmode()