-- public domain 20080407 lua@ztact.com require 'pozix' -- opendir ------------------------------------------------------------ opendir -- two ways to use opendir, readdir and closedir local dir = pozix.opendir ('.') print (dir) -- dir is userdata repeat local name = pozix.readdir (dir) if not name then break end print (name) until not name pozix.closedir (dir) dir = pozix.opendir ('.') for name in dir do print (name) end dir:close () -- or even more concisely for name in pozix.opendir ('.') do print (name) end -- stat ------------------------------------------------------------------ stat -- two ways to use stat local stat = pozix.stat ('.') print (stat) -- stat is userdata print (stat.mtime, stat.is_dir) local mtime, is_dir = pozix.stat ('.', 'mtime', 'is_dir') print (mtime, is_dir)