diff --git a/vcx2txt.ps1 b/vcx2txt.ps1 index 4196f32..cb4ff0b 100644 --- a/vcx2txt.ps1 +++ b/vcx2txt.ps1 @@ -94,13 +94,28 @@ function Convert-One($fullPath) { Copy-Item -LiteralPath $f.FullName -Destination $binCopy -Force if (Test-Path $memo) { Copy-Item -LiteralPath $memo -Destination (Join-Path $workDir (Split-Path $memo -Leaf)) -Force } - & $exe $binCopy '' '' '' '1' '0' '1' | Out-Null + # FoxBin2Prg.EXE e aplicatie GUI: "&" poate preda controlul inainte de final, iar stergerea + # binarului copiat ar omori conversia in curs -> Start-Process -Wait asteapta terminarea reala. + $started = Get-Date + $outLog = Join-Path $workDir ([IO.Path]::GetFileNameWithoutExtension($f.Name) + '.fb2p_out.tmp') + Start-Process -FilePath $exe -ArgumentList "`"$binCopy`" `"`" `"`" `"`" 1 0 1" -Wait -WindowStyle Hidden -RedirectStandardOutput $outLog + $exeOut = '' + if (Test-Path $outLog) { $exeOut = Get-Content -Raw $outLog; Remove-Item -LiteralPath $outLog -Force -ErrorAction SilentlyContinue } Remove-Item -LiteralPath $binCopy -Force -ErrorAction SilentlyContinue $memoCopy = Join-Path $workDir (Split-Path $memo -Leaf) if (Test-Path $memoCopy) { Remove-Item -LiteralPath $memoCopy -Force -ErrorAction SilentlyContinue } - if (Test-Path $txtOut) { return 'ok' } else { return 'fail' } + # succes = textul rescris acum SAU exe-ul raporteaza 0 erori (linia "O,P1,E0,S1,X0,"). + # FoxBin2Prg NU actualizeaza mtime cand textul regenerat e identic cu cel existent (ex. binar + # reatins de Project > Build fara schimbari reale) -> sincronizam mtime-ul textului, altfel + # fisierul pare stale si se reconverteste la fiecare rulare. + $fresh = (Test-Path $txtOut) -and ((Get-Item $txtOut).LastWriteTime -ge $started) + if ($fresh -or ((Test-Path $txtOut) -and ($exeOut -match ',E0,'))) { + if ((Get-Item $txtOut).LastWriteTime -lt $f.LastWriteTime) { (Get-Item $txtOut).LastWriteTime = Get-Date } + return 'ok' + } + return 'fail' } # --- Construieste lista de fisiere ---