summaryrefslogtreecommitdiff
path: root/compiler/finput.pas
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-04-10 19:20:48 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-04-10 19:20:48 +0000
commit160cc1e115eeb75638dce6effdd16b2bc810ddb4 (patch)
treeb791a95695a7cf674e61a6153139c6f9c6c491fa /compiler/finput.pas
parent3843727e74b31bbf2a34e7e3b89ee422269f770e (diff)
parent413a6aa6469e6c297780217a27ca91363c637944 (diff)
downloadfpc-avr.tar.gz
* rebase to trunk@17295avr
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/avr@17296 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/finput.pas')
-rw-r--r--compiler/finput.pas45
1 files changed, 22 insertions, 23 deletions
diff --git a/compiler/finput.pas b/compiler/finput.pas
index 47db6f7869..f385fcce0a 100644
--- a/compiler/finput.pas
+++ b/compiler/finput.pas
@@ -26,7 +26,7 @@ unit finput;
interface
uses
- cutils,cclasses;
+ cutils,cclasses,cstreams;
const
InputFileBufSize=32*1024+1;
@@ -91,7 +91,7 @@ interface
function fileclose: boolean; override;
procedure filegettime; override;
private
- f : file; { current file handle }
+ f : TCCustomFileStream; { current file handle }
end;
tinputfilemanager = class
@@ -457,47 +457,46 @@ uses
exit;
end;
{ Open file }
- ofm:=filemode;
- filemode:=0;
- Assign(f,filename);
- {$I-}
- reset(f,1);
- {$I+}
- filemode:=ofm;
- fileopen:=(ioresult=0);
+ fileopen:=false;
+ try
+ f:=CFileStreamClass.Create(filename,fmOpenRead);
+ fileopen:=true;
+ except
+ end;
end;
function tdosinputfile.fileseek(pos: longint): boolean;
begin
- {$I-}
- seek(f,Pos);
- {$I+}
- fileseek:=(ioresult=0);
+ fileseek:=false;
+ try
+ f.position:=Pos;
+ fileseek:=true;
+ except
+ end;
end;
function tdosinputfile.fileread(var databuf; maxsize: longint): longint;
- var
- w : longint;
begin
- blockread(f,databuf,maxsize,w);
- fileread:=w;
+ fileread:=f.Read(databuf,maxsize);
end;
function tdosinputfile.fileeof: boolean;
begin
- fileeof:=eof(f);
+ fileeof:=f.eof();
end;
function tdosinputfile.fileclose: boolean;
begin
- {$I-}
- system.close(f);
- {$I+}
- fileclose:=(ioresult=0);
+ fileclose:=false;
+ try
+ f.Free;
+ fileclose:=true;
+ except
+ end;
end;