2 -- Copyrigh (c) 2007, Bart Trojanowski <bart@jukie.net>
4 -- Simple wmiir like interface.
6 -- The current intent is to wrap around the wmiir executable.
7 -- This is just a proof of concept, and eventually this will
8 -- be rewritten in C to use libixp.
11 local io
= require("io")
12 local os
= require("os")
16 -- TODO I would like to be able to return an interator
17 function ls (dir
, fmt
)
18 local tmpfile
= os
.tmpname()
21 os
.execute ("wmiir ls " .. fmt
.. " " .. dir
.. " > " .. tmpfile
)
23 local fh
= io
.open (tmpfile
, "rb")
26 local data
= fh
:read("*a") -- read everything
33 -- TODO I would like to return a line iterator
35 local tmpfile
= os
.tmpname()
37 os
.execute ("wmiir read " .. file
.. " > " .. tmpfile
)
39 local fh
= io
.open (tmpfile
, "rb")
43 local line
= fh
:read("*l") -- read a line
45 io
.write ("-- closing " .. file
.. "\n")
52 -- write a value to a wmii virtual file system
53 function write (file
, value
)
54 os
.execute ("echo -n '" .. value
.. "' | wmiir write " .. file
)