root / trunk / ext / lua / yaml.lua

Revision 316, 0.5 kB (checked in by slact, 7 months ago)

no more segfaults on load. no more leaks loading or dumping. added info table. dumping still a bit sketchy for high nesting levels

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1-- borrow from lposix
2--
3require "syck"
4
5yaml = {}
6
7function yaml.dump(obj, io)
8        if io then
9                io:write(syck.dump(obj))
10        else
11                return syck.dump(obj)
12        end
13end
14
15function yaml.dump_file(obj, file)
16        local f, err = io.open(file, "w")
17        if not f then return nil, err end
18        f:write(yaml.dump(obj))
19        f:close()
20end
21
22function yaml.load(str)
23        return syck.load(str)
24end
25
26function yaml.load_file(file)
27        local f, err = io.open(file, "r")
28        if not f then return nil, err end
29        local ret = yaml.load(f:read("*all"))
30        f:close()
31        return ret
32end
33
34setmetatable(yaml, {__index=syck})
Note: See TracBrowser for help on using the browser.