param( [ValidateSet('Open', 'List', 'RefreshLetterBomb')] [string]$Action = 'Open', [string]$MacAddress = '02:00:00:43:18:01', [ValidateSet('E', 'U', 'J', 'K')] [string]$Region = 'E' ) $repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path $sdFolder = Join-Path $repoRoot 'Virtual-SD' $generator = Join-Path $repoRoot 'Tools\Generate-LetterBomb.py' $runningDolphin = Get-Process -Name DolphinNoGUI,Dolphin -ErrorAction SilentlyContinue if ($runningDolphin -and $Action -ne 'List') { throw 'Ferme Dolphin avant de modifier Virtual-SD : son arrêt resynchronise le dossier.' } if (-not (Test-Path -LiteralPath $sdFolder)) { New-Item -ItemType Directory -Path $sdFolder | Out-Null } switch ($Action) { 'Open' { Start-Process -FilePath 'explorer.exe' -ArgumentList @($sdFolder) } 'List' { Get-ChildItem -LiteralPath $sdFolder -Recurse -Force | Select-Object FullName, Length, LastWriteTime } 'RefreshLetterBomb' { $python = Get-Command python.exe -ErrorAction Stop & $python.Source $generator ` --mac $MacAddress ` --region $Region ` --output $sdFolder if ($LASTEXITCODE -ne 0) { throw "La génération de LetterBomb a échoué ($LASTEXITCODE)." } Write-Host 'LetterBomb actualisé. Il sera copié dans WiiSD.raw au prochain lancement.' } }