lua-users home
lua-l archive

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


To Whom It May Entertain:

Another functable [1], for LuaFileSystem this time around [2], or "Look Ma, no hands" :o)

http://dev.alt.textdrive.com/browser/HTTP/File.lua

Usage example:

local File = require( 'File' )

-- get the current directory
local aDirectory = File()

-- recursively enumerate its content
for aFile in aDirectory( true ) do
    print( aFile )
end

-- get some attributes
print( aDirectory, aDirectory.mode, aDirectory.size )

-- list all attributes
for aKey, aValue in pairs( aDirectory ) do
    print( aKey, aValue )
end

Main differences from plain LuaFileSystem:

- It's a functable! 8^)
- Recursive directory enumeration
- Bridge to the standard io package (e.g. aFile.content and aFile.content = 'bla' )

Cheers,

PA.

[1] http://lua-users.org/wiki/FuncTables
[2] http://article.gmane.org/gmane.comp.lang.lua.general/39571