Code cleanup based upon discussion comments

Added comment-based help parameter, added additional parameter
validation, piped ReadStream.seek command to out-null to prevent output
to stdout.
This commit is contained in:
garignack 2013-05-02 23:21:25 -04:00
parent acc46c71f7
commit 6d9d805f1e
1 changed files with 13 additions and 5 deletions

View File

@ -34,7 +34,11 @@ Specifies the path to the binary you want tested.
.PARAMETER OutPath .PARAMETER OutPath
Optionally specifies the directory to write the binaries to. Optionally specifies the directory to write the binaries to.
.PARAMETER BufferLen
Specifies the length of the file read buffer . Defaults to 64KB.
.PARAMETER Force .PARAMETER Force
Forces the script to continue without confirmation. Forces the script to continue without confirmation.
@ -61,7 +65,8 @@ http://heapoverflow.com/f0rums/project.php?issueid=34&filter=changes&page=2
[CmdletBinding()] Param( [CmdletBinding()] Param(
[Parameter(Mandatory = $True)] [Parameter(Mandatory = $True)]
[Int32] [ValidateRange(0,4294967295)]
[UInt32]
$StartByte, $StartByte,
[Parameter(Mandatory = $True)] [Parameter(Mandatory = $True)]
@ -69,7 +74,8 @@ http://heapoverflow.com/f0rums/project.php?issueid=34&filter=changes&page=2
$EndByte, $EndByte,
[Parameter(Mandatory = $True)] [Parameter(Mandatory = $True)]
[Int32] [ValidateRange(0,4294967295)]
[UInt32]
$Interval, $Interval,
[String] [String]
@ -79,7 +85,9 @@ http://heapoverflow.com/f0rums/project.php?issueid=34&filter=changes&page=2
[String] [String]
$OutPath = ($pwd), $OutPath = ($pwd),
[int]
[ValidateRange(1,2097152)]
[UInt32]
$BufferLen = 65536, $BufferLen = 65536,
[Switch] $Force [Switch] $Force
@ -143,7 +151,7 @@ http://heapoverflow.com/f0rums/project.php?issueid=34&filter=changes&page=2
Write-Verbose "Byte 0 -> $($SplitByte)" Write-Verbose "Byte 0 -> $($SplitByte)"
#Reset ReadStream to beginning of file #Reset ReadStream to beginning of file
$ReadStream.Seek(0, [System.IO.SeekOrigin]::Begin) $ReadStream.Seek(0, [System.IO.SeekOrigin]::Begin) | Out-Null
#Build a new FileStream for Writing #Build a new FileStream for Writing
[String] $outfile = Join-Path $OutPath "$($FileName)_$($SplitByte).bin" [String] $outfile = Join-Path $OutPath "$($FileName)_$($SplitByte).bin"