WORKAN DEBUG

This commit is contained in:
2026-09-25 16:10:17 -06:00
parent 4fea9dbccc
commit 608e225833
+22 -13
View File
@@ -130,7 +130,7 @@ process {
$helpInPath = $false;
if ($FilePath) {
foreach ($p in ($FilePath)) {
if ($p -match '^(?i)[-/]{1,2}(h\vert{}help\vert{}\?)$') {
if ($p -match '^(?i)[-/]{1,2}(h|help|\?)$') {
$helpInPath = $true;
break;
}
@@ -173,7 +173,7 @@ process {
};
if (-not $resolvedItems) {
Write-Error "checksum: $($pathEntry)`: No such file or directory";
Write-Error "checksum: $($pathEntry): No such file or directory";
continue;
};
@@ -232,7 +232,7 @@ process {
};
if (-not $checkFiles -or $checkFiles.Count -eq 0) {
Write-Error "checksum: $($Check)`: No such file or directory";
Write-Error "checksum: $($Check): No such file or directory";
return;
};
@@ -267,14 +267,16 @@ process {
$expectedHash = $Matches[1].ToLower();
$targetFile = $Matches[2].Trim().TrimStart('*');
}
elseif ($line -match '^([a-fA-F0-9]{128}\vert{}[a-fA-F0-9]{96}\vert{}[a-fA-F0-9]{64}\vert{}[a-fA-F0-9]{40}\vert{}[a-fA-F0-9]{32})[* ]?(.*)$') {
elseif ($line -match '^([a-fA-F0-9]{128}|[a-fA-F0-9]{96}|[a-fA-F0-9]{64}|[a-fA-F0-9]{40}|[a-fA-F0-9]{32})[* ]?(.*)$') {
$expectedHash = $Matches[1].ToLower();
$targetFile = $Matches[2].Trim().TrimStart('*');
};
if ($expectedHash -and $targetFile) {$targetFullPath = Join-Path -Path ($baseDir) -ChildPath ($targetFile);
if ($expectedHash -and $targetFile) {
$targetFullPath = Join-Path -Path ($baseDir) -ChildPath ($targetFile);
if (Test-Path -Path ($targetFullPath) -PathType 'Leaf') {$actualHash = (Get-FileHash -Path ($targetFullPath) -Algorithm ($fileAlgo)).Hash.ToLower();
if (Test-Path -Path ($targetFullPath) -PathType 'Leaf') {
$actualHash = (Get-FileHash -Path ($targetFullPath) -Algorithm ($fileAlgo)).Hash.ToLower();
$displayPath = Resolve-Path -Path ($targetFullPath) -Relative -ErrorAction 'SilentlyContinue';
if (-not $displayPath) { $displayPath = $targetFile; };
@@ -289,7 +291,8 @@ process {
};
} else {
$displayPath = $targetFile;
if ($baseDir -ne (Get-Location).Path) {$displayPath = Join-Path -Path (Resolve-Path -Path ($baseDir) -Relative -ErrorAction 'SilentlyContinue') -ChildPath ($targetFile);
if ($baseDir -ne (Get-Location).Path) {
$displayPath = Join-Path -Path (Resolve-Path -Path ($baseDir) -Relative -ErrorAction 'SilentlyContinue') -ChildPath ($targetFile);
if ($displayPath.StartsWith(".\") -or $displayPath.StartsWith("./")) { $displayPath = $displayPath.Substring(2); };
};
Write-Host "${displayPath}: " -NoNewline;
@@ -301,7 +304,8 @@ process {
}
# --- GENERATION MODE ---
else {
if ([string]::IsNullOrWhiteSpace($Algorithm)) {$Algorithm = 'SHA256';
if ([string]::IsNullOrWhiteSpace($Algorithm)) {
$Algorithm = 'SHA256';
};
$wantCustomOut = $PSBoundParameters.ContainsKey('OutFile');
@@ -316,13 +320,15 @@ process {
$dirPath = $group.Name;
$filesInDir = $group.Group;
if ($wantCustomOut) {$currentOutFile = Join-Path -Path ($dirPath) -ChildPath ($OutFile);
if ($wantCustomOut) {
$currentOutFile = Join-Path -Path ($dirPath) -ChildPath ($OutFile);
} else {
$currentOutFile = Join-Path -Path ($dirPath) -ChildPath "checksums.$($Algorithm.ToLower())";
};
$linesToWrite = @();
foreach ($item in ($filesInDir)) {$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($Algorithm)).Hash.ToLower();
foreach ($item in ($filesInDir)) {
$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($Algorithm)).Hash.ToLower();
$relativePath = $item.Name;
$outputLine = "${hash} ${relativePath}";
@@ -343,7 +349,8 @@ process {
};
$linesToWrite = @();
foreach ($item in ($allItems)) {$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($Algorithm)).Hash.ToLower();
foreach ($item in ($allItems)) {
$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($Algorithm)).Hash.ToLower();
$relativePath = Resolve-Path -Path ($item.FullName) -Relative -ErrorAction 'SilentlyContinue';
if (-not $relativePath) { $relativePath = $item.Name; };
@@ -360,7 +367,8 @@ process {
}
# Auto file for explicit individual files (No wildcard)
else {
foreach ($item in ($allItems)) {$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($Algorithm)).Hash.ToLower();
foreach ($item in ($allItems)) {
$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($Algorithm)).Hash.ToLower();
$relativePath = Resolve-Path -Path ($item.FullName) -Relative -ErrorAction 'SilentlyContinue';
if (-not $relativePath) { $relativePath = $item.Name; };
@@ -380,7 +388,8 @@ process {
}
# Standard console output (No save flags passed)
else {
foreach ($item in ($allItems)) {$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($Algorithm)).Hash.ToLower();
foreach ($item in ($allItems)) {
$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($Algorithm)).Hash.ToLower();
$relativePath = Resolve-Path -Path ($item.FullName) -Relative -ErrorAction 'SilentlyContinue';
if (-not $relativePath) { $relativePath = $item.Name; };