Skip to content

Commit 272cca9

Browse files
committed
Fixed some game extractions failing if program directory cannot be written to
Fixed ZIP SFX script extraction being tried for non-ZIP SFX executables
1 parent 240520c commit 272cca9

File tree

3 files changed

+41
-38
lines changed

3 files changed

+41
-38
lines changed

UniExtract.au3

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Const $zpaq = Quote($archdir & "zpaq.exe", True)
252252
Const $zoo = "unzoo.exe"
253253

254254
; Exractor plugins
255-
Const $bms = "BMS.bms"
255+
Const $bms = @TempDir & "\BMS.bms"
256256
Const $dbx = "dbxplug.wcx"
257257
Const $gaup = "gaup_pro.wcx"
258258
Const $ie = "InstExpl.wcx"
@@ -2212,6 +2212,28 @@ Func extract($arctype, $arcdisp = 0, $additionalParameters = "", $returnSuccess
22122212
_Run($7z & ' x "' & $outdir & '\' & $filename & '"', $outdir)
22132213
FileDelete($outdir & '\' & $filename)
22142214
EndIf
2215+
ElseIf StringInStr($sFileType, "SFX") Then
2216+
Cout("Trying to extract sfx script")
2217+
_CreateTrayMessageBox(t('SCANNING_FILE', "7z SFX Archives splitter"))
2218+
2219+
Run(_MakeCommand($7zsplit & ' "' & $file & '"'), $outdir, @SW_HIDE)
2220+
WinWait("7z SFX Archives splitter")
2221+
ControlClick("7z SFX Archives splitter", "", "Button8")
2222+
ControlClick("7z SFX Archives splitter", "", "Button1")
2223+
$TimerStart = TimerInit()
2224+
2225+
Do
2226+
Sleep(100)
2227+
If WinExists("7z SFX Archives splitter warning") Then WinClose("7z SFX Archives splitter warning")
2228+
$TimerDiff = TimerDiff($TimerStart)
2229+
If $TimerDiff > $Timeout Then ExitLoop
2230+
Until FileExists($filedir & "\" & $filename & ".txt") Or WinExists("7z SFX Archives splitter error")
2231+
2232+
ProcessClose("7ZSplit.exe")
2233+
_DeleteTrayMessageBox()
2234+
2235+
Local $sPath = $filedir & "\" & $filename & ".txt"
2236+
If FileExists($sPath) Then _FileMove($sPath, $outdir & "\" & $filename & "_SFX-Script.txt")
22152237
EndIf
22162238

22172239
Case $TYPE_ACE
@@ -2817,8 +2839,9 @@ Func extract($arctype, $arcdisp = 0, $additionalParameters = "", $returnSuccess
28172839
FileDelete($bindir & "rnd")
28182840

28192841
Case $TYPE_QBMS
2820-
_Run($quickbms & ' "' & $bindir & $additionalParameters & '" "' & $file & '" "' & $outdir & '"', $outdir, @SW_MINIMIZE, True, False)
2821-
If FileExists($bindir & $bms) Then FileDelete($bindir & $bms)
2842+
Local $sPlugin = $additionalParameters? $bindir & $additionalParameters: $bms
2843+
_Run($quickbms & ' "' & $sPlugin & '" "' & $file & '" "' & $outdir & '"', $outdir, @SW_MINIMIZE, True, False)
2844+
If FileExists($bms) Then FileDelete($bms)
28222845

28232846
If $additionalParameters == $ie Then
28242847
Local $aCleanup[] = ["[NSIS].nsi", "[LICENSE].*", "$PLUGINSDIR", "$TEMP", "uninstall.exe", "[LICENSE]"]
@@ -3234,29 +3257,6 @@ Func extract($arctype, $arcdisp = 0, $additionalParameters = "", $returnSuccess
32343257

32353258
Switch $success
32363259
Case $RESULT_SUCCESS
3237-
; Special actions for 7zip extraction
3238-
If $arctype == $TYPE_7Z And ($fileext = "exe" Or StringInStr($sFileType, "SFX")) Then
3239-
; Check if sfx archive and extract sfx script using 7ZSplit if possible
3240-
_CreateTrayMessageBox(t('SCANNING_FILE', "7z SFX Archives splitter"))
3241-
Cout("Trying to extract sfx script")
3242-
Run(_MakeCommand($7zsplit & ' "' & $file & '"'), $outdir, @SW_HIDE)
3243-
WinWait("7z SFX Archives splitter")
3244-
ControlClick("7z SFX Archives splitter", "", "Button8")
3245-
ControlClick("7z SFX Archives splitter", "", "Button1")
3246-
$TimerStart = TimerInit()
3247-
Do
3248-
Sleep(100)
3249-
If WinExists("7z SFX Archives splitter warning") Then WinClose("7z SFX Archives splitter warning")
3250-
$TimerDiff = TimerDiff($TimerStart)
3251-
If $TimerDiff > $Timeout Then ExitLoop
3252-
Until FileExists($filedir & "\" & $filename & ".txt") Or WinExists("7z SFX Archives splitter error")
3253-
; Force close all messages
3254-
ProcessClose("7ZSplit.exe")
3255-
3256-
; Move sfx script to outdir
3257-
If FileExists($filedir & "\" & $filename & ".txt") Then _FileMove($filedir & "\" & $filename & ".txt", $outdir & "\sfx_script_" & $filename & ".txt")
3258-
_DeleteTrayMessageBox()
3259-
EndIf
32603260

32613261
Case $RESULT_NOFREESPACE
32623262
terminate($STATUS_NOFREESPACE)
@@ -3369,19 +3369,18 @@ Func BmsExtract($sName, $hDB = 0)
33693369
If $hDB Then
33703370
Local $aReturn[0], $iRows, $iColumns
33713371
_SQLite_GetTable($hDB, Cout("SELECT s.Script FROM Scripts s, Names n WHERE s.SID = n.NID AND Name = '" & $sName & "'"), $aReturn, $iRows, $iColumns)
3372-
;~ _ArrayDisplay($aReturn)
33733372

33743373
; Write script to file and execute it
3375-
$bmsScript = FileOpen($bindir & $bms, $FO_OVERWRITE)
3376-
FileWrite($bmsScript, $aReturn[2])
3377-
FileClose($bmsScript)
3378-
$return = FetchStdout($quickbms & ' -l "' & $bindir & $bms & '" "' & $file & '"', $filedir, @SW_HIDE, -1)
3374+
$hFile = FileOpen($bms, $FO_OVERWRITE)
3375+
FileWrite($hFile, $aReturn[2])
3376+
FileClose($hFile)
3377+
$return = FetchStdout($quickbms & ' -l "' & $bms & '" "' & $file & '"', $filedir, @SW_HIDE, -1)
33793378

33803379
If Not StringInStr($return, "0 files found") And Not StringInStr($return, "Error") And Not StringInStr($return, "invalid") _
33813380
And Not StringInStr($return, "expected: ") And $return <> "" Then
33823381
_SQLite_Close($hDB)
33833382
_SQLite_Shutdown()
3384-
extract($TYPE_QBMS, $sName & " " & t('TERM_PACKAGE'), $bms)
3383+
extract($TYPE_QBMS, $sName & " " & t('TERM_PACKAGE'))
33853384
EndIf
33863385
EndIf
33873386

@@ -3391,10 +3390,16 @@ EndFunc
33913390
; Start SQLite and open a database
33923391
Func OpenDB($sName)
33933392
_SQLite_Startup()
3394-
If @error Then Return Cout("[ERROR] SQLite startup failed with code " & @error)
3393+
If @error Then
3394+
Cout("Error: SQLite startup failed with code " & @error)
3395+
Return False
3396+
EndIf
33953397

3396-
$hDB = _SQLite_Open($bindir & $sName, $SQLITE_OPEN_READONLY)
3397-
If @error Then Return Cout("[ERROR] Failed to open database " & $sName)
3398+
Local $hDB = _SQLite_Open($bindir & $sName, $SQLITE_OPEN_READONLY)
3399+
If @error Then
3400+
Cout("Error: Failed to open database " & $sName)
3401+
Return False
3402+
EndIf
33983403

33993404
Return $hDB
34003405
EndFunc

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Fixed some rare problems if the file extension contains upper case
55
Fixed DLLs being renamed to .exe if 'Fix file extensions' is enabled, thanks to demberto
66
Fixed 'File not found' errors after file got renamed by 'Fix file extensions' option, thanks to demberto
7+
Fixed some game extractions failing if program directory cannot be written to
78
Fixed several typos in English language file, thanks to Mr-Update
89
Changed design/usability of 'Execution warning' dialog
910
Updated cicdec to 2.1.1

todo.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ Unreal definition
3232

3333
// Other:
3434
Logging: quickbms (+ 'you must choose a new filename' user input needed detection)
35-
Rewrite 7z SFX extraction to use seperate $TYPE to make recursive 7z extract() run faster
3635
Consistency: $outdir should end with \
37-
Save BMS to temp
3836
Inno: detect encrypted error
3937
teelog dir
4038

@@ -47,7 +45,6 @@ Disk image status text
4745
investigate archive listing - req 44 // Add file list display for extractors that support it, create command line parameter, include into context menu
4846
smart extraction - archive contains: single file/folder -> file dir; multiple files -> sub dir; folder with same name as filedir && filedir only contains archive -> files into filedir
4947
global ignore list, e.g. don't extract .url files, readme.txt, etc.
50-
include tridscan gui?
5148
generic error message for failed extraction: check if only some file has errors and display different error message
5249

5350

0 commit comments

Comments
 (0)