summaryrefslogtreecommitdiff
path: root/compiler/finput.pas
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-04-05 20:10:09 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-04-05 20:10:09 +0000
commit2791d0047afc3b719f66a661caf3640c222cbdbe (patch)
tree35fc94b58e18bbb5cf9aa3e73cfe4dd04b583395 /compiler/finput.pas
parentb7cc22ee5e2e9782ab195e299e648b1bff4e689f (diff)
downloadfpc-2791d0047afc3b719f66a661caf3640c222cbdbe.tar.gz
* patch by Mattias Gaertner to allow to override how the compiler reads source/ppu files, resolves #18740
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@17255 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;