我有一個與lua文件接口的C++應用程序。我有一個提取zip文件的lua文件,當我使用SciTe或Lua命令行運行時,它可以工作。但是當我嘗試從C++應用程序運行它時,它似乎不起作用。從C++應用程序調用時,爲什麼不luazip提取文件?
require "zip"
function ExtractZipFiles(zipFilename, destinationPath)
zipFile, err = zip.open(zipFilename)
-- iterate through each file insize the zip file
for file in zipFile:files() do
currentFile, err = zipFile:open(file.filename)
currentFileContents = currentFile:read("*a") -- read entire contents of current file
currentFile:close()
hBinaryOutput = io.open(destinationPath .. file.filename, "wb")
-- write current file inside zip to a file outside zip
if(hBinaryOutput)then
hBinaryOutput:write(currentFileContents)
hBinaryOutput:close()
end
end
zipFile:close()
end
-- Unit Test
ExtractZipFiles("SZProcessTests.zip", "Infections\\")
如果我有Lua的計算機上安裝和運行的LUA雙擊文件和按預期的方式提取文件。
void CSZTestClientMessagesDlg::OnBtnExecute()
{
L = lua_open();
luaL_openlibs(L);
luaL_dofile(L, "ExtractZipFiles.lua");
lua_close(L);
return;
}
你會得到什麼錯誤? – 2010-05-20 20:04:58