Commits

Palmer, 2E0EOL committed bd4f580

Start brainstorming the _ValidateWhence() function

  • Participants
  • Parent commits 365733e

Comments (0)

Files changed (1)

 	}
 }
 #----------------------------------------------------------------------------
+sub _ValidateWhence
+{
+	my $self = undef; # Optional reference to self
+	my $absOffset;
+	my ( $Whence, $Offset );
+	if ( $_[0] ) {
+		my $r = ref($_[0]);
+		$self = shift if ( $r && $r eq __PACKAGE__ );
+	}
+
+	( $Whence, $Offset ) = @_;
+	{ # Check Whence is valid
+		my $whence_ok = FALSE();
+		if ( $Whence =~ m/^\-?\d$/ ) {
+			$whence_ok = TRUE()
+				if ( $Whence >= _SEEK_MIN() && $Whence <= _SEEK_MAX() );
+		}
+		return $whence_ok if ( !$whence_ok );
+	}
+
+	# Change the relative offset into the absolute offset
+	$absOffset = $Offset;
+	if ( $self ) {
+		my $curOffset = $self->{_pos};
+		$curOffset = 0 if ( $curOffset < 0 );
+		if ( $Whence == SEEK_CUR() ) {
+			$absOffset += $self->{_pos};
+		} elsif ( $Whence == SEEK_END() ) {
+			xxx
+#----------------------------------------------------------------------------
 package Verifier;
 use strict;
 use warnings;