I believe I have a solution.
Part of the problem was that the code snippet did not take account of existing items in the target folder.
But that is further confounded by the
Research Planner Plugin creating the
Research Planner Help 2.0 subfolder before extracting the ZIP file. Therefore, extracting the ZIP adds no items to the target folder
Research Planner.dat and so there is nothing to count in that folder to check the extraction has worked.
BTW: The earlier version of
function extractZip(...), and the original code snippet, did not correctly detect or return a
true/
false indication of ZIP file extraction.
I have modified the
function extractZip(...) code snippet to account for existing items.
I have deleted the
lfs.mkdir(HelpFileDirectory) from
local function GetHelpFile().
Now
extractZip(...) correctly returns
true or
false depending on whether the extraction adds any item(s), which in this case is just the
Research Planner Help 2.0 subfolder.
I will see if the
function buildZip(...) needs a similar treatment.
Code: Select all
function extractZip(zipFile,folder)
-- Create com object to work with Files and Folders
local shell = luacom.CreateObject("Shell.Application")
local source = shell:NameSpace(zipFile) -- Get the zip file
local items = source:items()
local dest = shell:NameSpace(folder) -- Get the destination folder file
local files = dest:items().count + items.count -- Count of top level items already in folder plus those in zip file
dest:CopyHere(items) -- Copy the Zip to the Folder
repeat -- Check that copy of Zip completed
local count = dest:items().count
if count == files then return true end
fhSleep(1000,500)
until count == dest:items().count
return false
end