-vlc.msg.info("About to compile lua file")
-vlc.msg.info(" Input is '"..tostring(config.input).."'")
-vlc.msg.info(" Output is '"..tostring(config.output).."'")
+function compile()
+ vlc.msg.info("About to compile lua file")
+ vlc.msg.info(" Input is '"..tostring(config.input).."'")
+ vlc.msg.info(" Output is '"..tostring(config.output).."'")
+ if not config.input or not config.output then
+ vlc.msg.err("Input and output config options must be set")
+ return false
+ end
+
+ local bytecode, msg = loadfile(config.input)
+ if not bytecode then
+ vlc.msg.err("Error while loading file '"..config.input.."': "..msg)
+ return false
+ end
+
+ local output, msg = io.open(config.output, "wb")
+ if not output then
+ vlc.msg.err("Error while opening file '"..config.output.."' for output: "..msg)
+ return false
+ else
+ output:write(string.dump(bytecode))
+ return true
+ end
+end