waypoint debugging
This commit is contained in:
@@ -145,16 +145,16 @@ process {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
# Added explicit semicolons here to prevent copy-paste line-break parsing errors
|
|
||||||
$allItems = @();
|
$allItems = @();
|
||||||
$isWildcardGlobal =$false;
|
$isWildcardGlobal =$false;
|
||||||
$skipExtensions = @('.md5', '.sha1', '.sha256', '.sha384', '.sha512');
|
$skipExtensions = @('.md5', '.sha1', '.sha256', '.sha384', '.sha512');
|
||||||
|
|
||||||
foreach ($pathEntry in$FilePath) {
|
# Delimiting collection in parentheses prevents space-stripping errors
|
||||||
$isWildcard = ($pathEntry -match '\*')
|
foreach ($pathEntry in ($FilePath)) {
|
||||||
|
$isWildcard = ($pathEntry -match '\*');
|
||||||
if ($isWildcard) { $isWildcardGlobal =$true }
|
if ($isWildcard) { $isWildcardGlobal =$true }
|
||||||
|
|
||||||
$resolvedItems = @()
|
$resolvedItems = @();
|
||||||
if ($Recursive) {
|
if ($Recursive) {
|
||||||
$resolvedItems = Get-ChildItem -Path$pathEntry -Recurse -File -ErrorAction SilentlyContinue
|
$resolvedItems = Get-ChildItem -Path$pathEntry -Recurse -File -ErrorAction SilentlyContinue
|
||||||
} else {
|
} else {
|
||||||
@@ -170,12 +170,12 @@ process {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
$explicitFileFound = $false
|
$explicitFileFound = $false;
|
||||||
if ((-not $isWildcard) -and (Test-Path -Path $pathEntry -PathType Leaf)) {
|
if ((-not $isWildcard) -and (Test-Path -Path $pathEntry -PathType Leaf)) {
|
||||||
$explicitFileFound = $true
|
$explicitFileFound = $true
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($item in $resolvedItems) {
|
foreach ($item in ($resolvedItems)) {
|
||||||
if ($item.PSIsContainer) { continue }
|
if ($item.PSIsContainer) { continue }
|
||||||
|
|
||||||
# Feature 1: Skip checksum extension files unless they were named explicitly
|
# Feature 1: Skip checksum extension files unless they were named explicitly
|
||||||
@@ -197,11 +197,12 @@ process {
|
|||||||
Write-Verbose "Auto-detected algorithm: $Algorithm"
|
Write-Verbose "Auto-detected algorithm: $Algorithm"
|
||||||
}
|
}
|
||||||
|
|
||||||
$expectedHash = $Match.Trim().ToLower()
|
$expectedHash = $Match.Trim().ToLower();
|
||||||
|
|
||||||
foreach ($item in $allItems) {
|
foreach ($item in ($allItems)) {
|
||||||
$actualHash = (Get-FileHash -Path $item.FullName -Algorithm $Algorithm).Hash.ToLower()
|
$actualHash = (Get-FileHash -Path $item.FullName -Algorithm $Algorithm).Hash.ToLower()
|
||||||
$targetFile = Resolve-Path -Path $item.FullName -Relative
|
$targetFile = Resolve-Path -Path $item.FullName -Relative -ErrorAction SilentlyContinue
|
||||||
|
if (-not $targetFile) { $targetFile = $item.Name }
|
||||||
if ($targetFile.StartsWith(".\")) { $targetFile = $targetFile.Substring(2) }
|
if ($targetFile.StartsWith(".\")) { $targetFile = $targetFile.Substring(2) }
|
||||||
|
|
||||||
if ($actualHash -eq $expectedHash) {
|
if ($actualHash -eq $expectedHash) {
|
||||||
@@ -215,7 +216,7 @@ process {
|
|||||||
}
|
}
|
||||||
# --- VERIFICATION MODE (-c / -Check) ---
|
# --- VERIFICATION MODE (-c / -Check) ---
|
||||||
elseif ($PSCmdlet.ParameterSetName -eq 'Verify') {
|
elseif ($PSCmdlet.ParameterSetName -eq 'Verify') {
|
||||||
$checkFiles = @()
|
$checkFiles = @();
|
||||||
if ($Recursive) {
|
if ($Recursive) {
|
||||||
# Find all files matching the name of $Check recursively
|
# Find all files matching the name of $Check recursively
|
||||||
$checkFileName = Split-Path $Check -Leaf
|
$checkFileName = Split-Path $Check -Leaf
|
||||||
@@ -231,13 +232,13 @@ process {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($cf in$checkFiles) {
|
foreach ($cf in ($checkFiles)) {
|
||||||
$lines = Get-Content -Path$cf.FullName
|
$lines = Get-Content -Path$cf.FullName
|
||||||
$baseDir =$cf.DirectoryName
|
$baseDir =$cf.DirectoryName
|
||||||
|
|
||||||
$fileAlgo =$Algorithm
|
$fileAlgo =$Algorithm
|
||||||
if ([string]::IsNullOrWhiteSpace($fileAlgo)) {
|
if ([string]::IsNullOrWhiteSpace($fileAlgo)) {
|
||||||
foreach ($line in$lines) {
|
foreach ($line in ($lines)) {
|
||||||
if ([string]::IsNullOrWhiteSpace($line) -or$line.StartsWith("#")) { continue }
|
if ([string]::IsNullOrWhiteSpace($line) -or$line.StartsWith("#")) { continue }
|
||||||
if ($line -match '^([a-fA-F0-9]+)\s+') {
|
if ($line -match '^([a-fA-F0-9]+)\s+') {
|
||||||
$fileAlgo = Get-AlgorithmFromHashLength -HashString$Matches[1]
|
$fileAlgo = Get-AlgorithmFromHashLength -HashString$Matches[1]
|
||||||
@@ -248,7 +249,7 @@ process {
|
|||||||
if ([string]::IsNullOrWhiteSpace($fileAlgo)) {$fileAlgo = 'SHA256' }
|
if ([string]::IsNullOrWhiteSpace($fileAlgo)) {$fileAlgo = 'SHA256' }
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($line in$lines) {
|
foreach ($line in ($lines)) {
|
||||||
if ([string]::IsNullOrWhiteSpace($line) -or$line.StartsWith("#")) { continue }
|
if ([string]::IsNullOrWhiteSpace($line) -or$line.StartsWith("#")) { continue }
|
||||||
|
|
||||||
if ($line -match '^([a-fA-F0-9]+)\s+[* ]?(.*)$') {
|
if ($line -match '^([a-fA-F0-9]+)\s+[* ]?(.*)$') {
|
||||||
@@ -260,7 +261,8 @@ process {
|
|||||||
|
|
||||||
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
|
$displayPath = Resolve-Path -Path$targetFullPath -Relative -ErrorAction SilentlyContinue
|
||||||
|
if (-not $displayPath) { $displayPath =$targetFile }
|
||||||
if ($displayPath.StartsWith(".\")) { $displayPath =$displayPath.Substring(2) }
|
if ($displayPath.StartsWith(".\")) { $displayPath =$displayPath.Substring(2) }
|
||||||
|
|
||||||
if ($actualHash -eq$expectedHash) {
|
if ($actualHash -eq$expectedHash) {
|
||||||
@@ -273,7 +275,7 @@ process {
|
|||||||
} else {
|
} else {
|
||||||
# Format missing path nicely
|
# Format missing path nicely
|
||||||
$displayPath =$targetFile
|
$displayPath =$targetFile
|
||||||
if ($baseDir -ne (Get-Location).Path) {$displayPath = Join-Path -Path (Resolve-Path -Path $baseDir -Relative) -ChildPath$targetFile
|
if ($baseDir -ne (Get-Location).Path) {$displayPath = Join-Path -Path (Resolve-Path -Path $baseDir -Relative -ErrorAction SilentlyContinue) -ChildPath$targetFile
|
||||||
if ($displayPath.StartsWith(".\")) { $displayPath =$displayPath.Substring(2) }
|
if ($displayPath.StartsWith(".\")) { $displayPath =$displayPath.Substring(2) }
|
||||||
}
|
}
|
||||||
Write-Host "${displayPath}: " -NoNewline
|
Write-Host "${displayPath}: " -NoNewline
|
||||||
@@ -299,7 +301,7 @@ process {
|
|||||||
if ($Recursive -and$isWildcardGlobal) {
|
if ($Recursive -and$isWildcardGlobal) {
|
||||||
$groupedItems =$allItems | Group-Object DirectoryName
|
$groupedItems =$allItems | Group-Object DirectoryName
|
||||||
|
|
||||||
foreach ($group in$groupedItems) {
|
foreach ($group in ($groupedItems)) {
|
||||||
$dirPath =$group.Name
|
$dirPath =$group.Name
|
||||||
$filesInDir =$group.Group
|
$filesInDir =$group.Group
|
||||||
|
|
||||||
@@ -312,7 +314,7 @@ process {
|
|||||||
# Clear existing file before iterating
|
# Clear existing file before iterating
|
||||||
$null = New-Item -Path$currentOutFile -ItemType File -Force
|
$null = New-Item -Path$currentOutFile -ItemType File -Force
|
||||||
|
|
||||||
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 # Localization relies purely on internal filenames
|
$relativePath =$item.Name # Localization relies purely on internal filenames
|
||||||
|
|
||||||
$outputLine = "$hash$relativePath"
|
$outputLine = "$hash$relativePath"
|
||||||
@@ -323,7 +325,7 @@ process {
|
|||||||
}
|
}
|
||||||
# Non-localized standard generation (Singular master file, or Per-file auto naming)
|
# Non-localized standard generation (Singular master file, or Per-file auto naming)
|
||||||
else {
|
else {
|
||||||
$singleOutFile =$null
|
$singleOutFile =$null;
|
||||||
|
|
||||||
# Check for standard auto naming rules
|
# Check for standard auto naming rules
|
||||||
if ([string]::IsNullOrWhiteSpace($outFilename)) {
|
if ([string]::IsNullOrWhiteSpace($outFilename)) {
|
||||||
@@ -338,9 +340,10 @@ process {
|
|||||||
$null = New-Item -Path$singleOutFile -ItemType File -Force
|
$null = New-Item -Path$singleOutFile -ItemType File -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
$relativePath = Resolve-Path -Path$item.FullName -Relative -ErrorAction SilentlyContinue
|
||||||
|
if (-not $relativePath) { $relativePath =$item.Name }
|
||||||
if ($relativePath.StartsWith(".\")) {
|
if ($relativePath.StartsWith(".\")) {
|
||||||
$relativePath =$relativePath.Substring(2)
|
$relativePath =$relativePath.Substring(2)
|
||||||
}
|
}
|
||||||
@@ -362,9 +365,10 @@ process {
|
|||||||
}
|
}
|
||||||
# Standard fallback if no -o was invoked: Stream perfectly to console
|
# Standard fallback if no -o was invoked: Stream perfectly to console
|
||||||
else {
|
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
|
$relativePath = Resolve-Path -Path$item.FullName -Relative -ErrorAction SilentlyContinue
|
||||||
|
if (-not $relativePath) { $relativePath =$item.Name }
|
||||||
if ($relativePath.StartsWith(".\")) {
|
if ($relativePath.StartsWith(".\")) {
|
||||||
$relativePath =$relativePath.Substring(2)
|
$relativePath =$relativePath.Substring(2)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user