PEDB
I did find some success by checking if the directory or file exists using sys module, since the files just need the directory to exist in the first place. so the solution is knowing where the app launched, checking directories and making the missing ones.
if it returns false or nil then i simply GSUB the filename from the fullpath for that file in the app Directory and extract like some of the examples do, its a bit hacky but luart provides where it was launched from via run args (i believe its -1 index)
i hope this helps at all, i had noticed a bug like this as well. i noticed LuaRT will simply not "unpack" if the source or path is missing as noted in its sys module copy file example. I also played with using shell commands to do this, better success but requires checking after and failed install handler
This is how i get the "runpath" from where the program launched:
string.match(arg[-1], "(.*)\\[^\\]+$")
And this is how i handle missing directories before i try extracting:
--Grab/Make Directory
local TP = sys.Directory(TempPath)
if TP:make() then
print("Directory Exist/Made: "..tostring(TP.fullpath), {Src="Installer"})
end
Full example, though this is a snippet. its the file coping you may be interested in
if not ObjData.Installed then
--finish this part (TODO, left off here. read above)
if StudioFlag and not embed then
--Working (i was trying to copy back to installer not runfolder like a dumbass)
local TempPath = string.gsub(ObjData.DestPath, "[/\\][^/\\]+$", "")
print(TempPath, {Src="TempPath"})
--Grab/Make Directory
local TP = sys.Directory(TempPath)
if TP:make() then
print("Directory Exist/Made: "..tostring(TP.fullpath), {Src="Installer"})
end
--Then Make the File it self (Can be done right after making the Directory)
print("Directory Exists, Copying File to New Path", {Src="Installer"})
local TempFile = sys.File(ObjData.Path) --Grab Original (.Path)
local NF = TempFile:copy(ObjData.DestPath) --To New Location (.DestPath)
--Then Check for Install State
local TEMPFileC, Color2 = sys.File(ObjData.DestPath).exists, "lightgreen"
if not TEMPFileC then Color2 = "red" else ObjData.File = sys.File(ObjData.DestPath) ObjData.Installed = true end
print(ObjData.DestPath..": "..tostring(TEMPFileC), {Src = "Installer-STATE", Color=Color2})
else--if not studio mode then extract as usual and return a table refering all files (Sort by filename)
--print("Checking: @"..Obj.." \n ~File Dest Path: "..tostring(ObjData.DestPath).." \n ~File Source Path: "..tostring(ObjData.Path).." \n ~File Installed?: "..tostring(ObjData.Installed), {Src = "Installer2"})
--Grab/Make Directory
local TempPath = string.gsub(ObjData.DestPath, "[/\\][^/\\]+$", "")
print(TempPath, {Src="TempPath"})
local TP = sys.Directory(TempPath)
if TP:make() then
print("Directory Exists/Made: "..tostring(TP.fullpath), {Src="Installer"})
end
--then extract from embed
print("awaiting file: "..tostring(ObjData.Path), {Src = "Installer-DOING", Color="yellow"})
EmbData:extract(ObjData.DestPath) --Grab Original (.Path) (NOT THE FULL SOURCE PATH)
--A more advanced Check, if installed to Temp then the path we fed was not full or correct. otherwise act as before
local TEMPFileC, Color2 = sys.File(ObjData.Path).exists, "lightgreen"
if not TEMPFileC then
Color2 = "red"
elseif string.find(ObjData.Path, "AppData\\Local\\Temp\\") then
Color2 = "yellow"
ObjData.Path = ObjData.File.fullpath
print(ObjData.DestPath..": \nWas Installed to "..tostring(ObjData.Path)..", This is an Error. Configs are now hard coded default or at that location!", {Src = "Installer-ERROR", Color="red"})
else
ObjData.File = sys.File(ObjData.Path) ObjData.Installed = sys.File(ObjData.Path).exists
end
--status
print(ObjData.Path..": "..tostring(TEMPFileC), {Src = "Installer-STATE", Color=Color2})
end
else