-- file functions
-- list files
function ls()
l=file.list()
for k,v in pairs(l) do
print("\t"..k.."\t"..v)
end
end
-- show contents of file
function cat(fname)
file.open(fname,"r")
l=file.readline()
while l~=nil do
print(string.sub(l,1,-2))
l=file.readline()
end
end
-- delete all files
function wipe()
l=file.list()
for k in pairs(l) do
file.remove(k)
end
end
-- misc helper functions
-- list members of object
function dir(o)
for k,v in pairs(o) do
print(k)
end
end
-- string to hex
function str2hex(s)
r=""
for i=1,string.len(s) do
r = r .. string.format("%02x",string.byte(s,i))
end
return r
end