mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-27 14:36:30 +01:00
Co-authored-by: DrPerkyLegit <116128211+DrPerkyLegit@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Anaël <60509176+Bakoubak@users.noreply.github.com> Reviewed-on: https://git.neolegacy.dev/neoStudiosLCE/neoLegacy/pulls/4205
28 lines
983 B
PowerShell
28 lines
983 B
PowerShell
param([string]$Bank, [string]$Filter = '', [string]$OutDir = '')
|
|
|
|
$data = [System.IO.File]::ReadAllBytes($Bank)
|
|
$text = [System.Text.Encoding]::GetEncoding(28591).GetString($data)
|
|
$pattern = 'Minecraft/([A-Za-z0-9_/]+)\x00\*(\d+)\*(\d+)\.binka'
|
|
|
|
$seen = @{}
|
|
foreach ($m in [regex]::Matches($text, $pattern)) {
|
|
$name = $m.Groups[1].Value
|
|
if ($Filter -and $name -notlike "*$Filter*") { continue }
|
|
if ($seen.ContainsKey($name)) { continue }
|
|
$seen[$name] = 1
|
|
$size = [int64]$m.Groups[2].Value
|
|
$off = [int64]$m.Groups[3].Value
|
|
if ($off + $size -gt $data.Length) { Write-Warning "$name is outside the bank"; continue }
|
|
|
|
if ($OutDir) {
|
|
$path = Join-Path $OutDir ($name + '.binka')
|
|
New-Item -ItemType Directory -Force (Split-Path $path) | Out-Null
|
|
$buf = New-Object byte[] $size
|
|
[Array]::Copy($data, $off, $buf, 0, $size)
|
|
[System.IO.File]::WriteAllBytes($path, $buf)
|
|
}
|
|
else {
|
|
"$name $size $off"
|
|
}
|
|
}
|