docs: setup_extract.ps1
Browse files- setup_extract.ps1 +44 -0
setup_extract.ps1
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
param([string]$OutDir = "")
|
| 2 |
+
$ErrorActionPreference = "Stop"
|
| 3 |
+
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
| 4 |
+
$TarName = "DressCode.tar"
|
| 5 |
+
$TarPath = Join-Path $ScriptDir $TarName
|
| 6 |
+
if (-not $OutDir) { $OutDir = Join-Path $ScriptDir "data\DressCode" }
|
| 7 |
+
|
| 8 |
+
function Join-Parts([string]$OutFile) {
|
| 9 |
+
$parts = Get-ChildItem -Path ($OutFile + ".part*") -EA SilentlyContinue | Sort-Object Name
|
| 10 |
+
if (-not $parts -or $parts.Count -eq 0) { return $false }
|
| 11 |
+
Write-Host "==> Joining $($parts.Count) parts -> $OutFile"
|
| 12 |
+
if (Test-Path $OutFile) { Remove-Item $OutFile -Force }
|
| 13 |
+
$fs = [System.IO.File]::Open($OutFile, 'Create')
|
| 14 |
+
try {
|
| 15 |
+
foreach ($p in $parts) {
|
| 16 |
+
Write-Host " + $($p.Name)"
|
| 17 |
+
$src = [System.IO.File]::OpenRead($p.FullName)
|
| 18 |
+
try { $src.CopyTo($fs) } finally { $src.Dispose() }
|
| 19 |
+
}
|
| 20 |
+
} finally { $fs.Dispose() }
|
| 21 |
+
return $true
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
if (-not (Test-Path $TarPath)) {
|
| 25 |
+
if (-not (Join-Parts $TarPath)) { Write-Error "Missing $TarPath / parts" }
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
$parent = Split-Path -Parent $OutDir
|
| 29 |
+
New-Item -ItemType Directory -Force -Path $parent | Out-Null
|
| 30 |
+
Write-Host "==> Extracting $TarName -> $parent"
|
| 31 |
+
& tar.exe -xf $TarPath -C $parent
|
| 32 |
+
if ($LASTEXITCODE -ne 0) { throw "tar extract failed" }
|
| 33 |
+
|
| 34 |
+
$Root = $OutDir
|
| 35 |
+
foreach ($c in @((Join-Path $parent "DressCode"), (Join-Path $OutDir "DressCode"), $OutDir)) {
|
| 36 |
+
if (Test-Path (Join-Path $c "dresses")) { $Root = $c; break }
|
| 37 |
+
}
|
| 38 |
+
$missing = $false
|
| 39 |
+
foreach ($n in @("dresses", "upper_body", "lower_body")) {
|
| 40 |
+
if (-not (Test-Path (Join-Path $Root $n))) { Write-Host " MISSING: $n"; $missing = $true }
|
| 41 |
+
else { Write-Host " OK: $n" }
|
| 42 |
+
}
|
| 43 |
+
if ($missing) { throw "layout check failed" }
|
| 44 |
+
Write-Host "==> Done. Dataset root: $Root"
|