Skip to content

Commit b618da3

Browse files
author
LocalIdentity
committed
Use copy file command to speed up export
Now runs in 0.1s instead of 8s
1 parent 1b7bd25 commit b618da3

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/Export/Scripts/passivetree_ggg.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,10 @@ for _, strFile in ipairs(fileAssets) do
646646

647647
-- this file contains frame & meta
648648
local fileNameMeta = dataFrame.meta.image
649-
-- copy the file to tree data destination
650-
-- this assume you are on windows
651-
local copyResult = os.execute(string.format('copy /Y "%s\\%s" "%s"', assetsFolder, fileNameMeta, path))
652-
if copyResult ~= 0 then
649+
local copied, copyErr = copyFile(assetsFolder .. "\\" .. fileNameMeta, path .. fileNameMeta)
650+
if not copied then
653651
printf("Error copying asset " .. fileNameMeta)
652+
printf(copyErr)
654653
return
655654
end
656655

src/Modules/Common.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,11 +801,11 @@ function getFormatSec(dec)
801801
end
802802

803803
function copyFile(srcName, dstName)
804-
local inFile, msg = io.open(srcName, "r")
804+
local inFile, msg = io.open(srcName, "rb")
805805
if not inFile then
806806
return nil, "Couldn't open '"..srcName.."': "..msg
807807
end
808-
local outFile, msg = io.open(dstName, "w")
808+
local outFile, msg = io.open(dstName, "wb")
809809
if not outFile then
810810
return nil, "Couldn't create '"..dstName.."': "..msg
811811
end

0 commit comments

Comments
 (0)