Browse Source

* Error when seek fails

git-svn-id: trunk@47056 -
michael 4 years ago
parent
commit
722e8d94cd
2 changed files with 5 additions and 1 deletions
  1. 1 0
      rtl/objpas/sysconst.pp
  2. 4 1
      rtl/objpas/sysutils/filutil.inc

+ 1 - 0
rtl/objpas/sysconst.pp

@@ -100,6 +100,7 @@ const
   SSafecallException     = 'Exception in safecall method';
   SSafecallException     = 'Exception in safecall method';
   SiconvError            = 'iconv error';
   SiconvError            = 'iconv error';
   SThreadError           = 'Thread error';
   SThreadError           = 'Thread error';
+  SSeekFailed            = 'Seek operation failed';
 
 
   STooManyOpenFiles      = 'Too many open files';
   STooManyOpenFiles      = 'Too many open files';
   SUnKnownRunTimeError   = 'Unknown Run-Time error : %3.3d';
   SUnKnownRunTimeError   = 'Unknown Run-Time error : %3.3d';

+ 4 - 1
rtl/objpas/sysutils/filutil.inc

@@ -711,7 +711,10 @@ Var
 
 
 begin
 begin
   aLen:=FileSeek(aHandle,0,fsFromEnd);
   aLen:=FileSeek(aHandle,0,fsFromEnd);
-  FileSeek(aHandle,0,fsFromBeginning);
+  if aLen<0 then
+    Raise EInOutError.Create(SSeekFailed);
+  if FileSeek(aHandle,0,fsFromBeginning)<0 then
+    Raise EInOutError.Create(SSeekFailed);
   SetLength(Result,aLen);
   SetLength(Result,aLen);
   aOffset:=0;
   aOffset:=0;
   Repeat
   Repeat