Recent Posts
None | 52 sec ago
None | 1 min ago
None | 1 min ago
Java | 1 min ago
Java | 1 min ago
Java | 2 min ago
None | 2 min ago
None | 2 min ago
Python | 3 min ago
None | 3 min ago
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
By Anonymous on the 9th of Feb 2010 11:23:13 PM
Download |
Raw |
Embed |
Report
local alien = require 'alien'
local structs = require 'structs'
local struct = require 'alien.struct'
local function listdir(path)
local result = {}
local libc = alien.default
libc.strerror:types("string", "int")
libc.opendir:types("pointer", "string")
libc.readdir:types("pointer", "pointer")
libc.closedir:types("int", "pointer")
local dirh = libc.opendir(path)
if (dirh == nil) then
err = alien.errno()
merr = libc.strerror(err)
log.crit("opendir('%s') returned: errno=(%d) %s", tostring(path), err, merr)
error("Failed to open: ".. path)
end
while true do
dp = libc.readdir(dirh)
if dp == nil then
break
end
local s = struct.unpack("s", dp, structs.dirent.__size, structs.dirent.d_name + 1)
log.crit("str: %d: %s", structs.dirent.d_name, s)
table.insert(result, s)
end
return result
end
Submit a correction or amendment below.
Make A New Post