|
@@ -47,9 +47,23 @@ unit iso7185;
|
|
|
|
|
|
Procedure Get(Var f: TypedFile);
|
|
|
Procedure Put(Var f: TypedFile);
|
|
|
+ Procedure Seek(var f:TypedFile;Pos:Int64);
|
|
|
+ Function FilePos(var f:TypedFile):Int64;
|
|
|
|
|
|
Function Eof(var f:TypedFile): Boolean;
|
|
|
|
|
|
+{$ifdef FPC_CURRENCY_IS_INT64}
|
|
|
+{$ifndef FPUNONE}
|
|
|
+ function round(c : currency) : int64;
|
|
|
+{$endif FPUNONE}
|
|
|
+{$ifndef cpujvm}
|
|
|
+ function round(c : comp) : int64;
|
|
|
+{$else not cpujvm}
|
|
|
+ function round_comp(c : comp) : int64;
|
|
|
+{$endif not cpujvm}
|
|
|
+{$endif FPC_CURRENCY_IS_INT64}
|
|
|
+ function Round(d : ValReal) : int64;
|
|
|
+
|
|
|
implementation
|
|
|
|
|
|
|
|
@@ -130,7 +144,7 @@ unit iso7185;
|
|
|
else
|
|
|
begin
|
|
|
OldCtrlZMarksEof:=CtrlZMarksEOF;
|
|
|
- CtrlZMarksEof:=false;
|
|
|
+ CtrlZMarksEof:=true;
|
|
|
Eof:=System.Eof(t);
|
|
|
CtrlZMarksEof:=OldCtrlZMarksEOF;
|
|
|
end;
|
|
@@ -193,13 +207,13 @@ unit iso7185;
|
|
|
procedure Get(var f:TypedFile);[IOCheck];
|
|
|
Begin
|
|
|
if not(eof(f)) then
|
|
|
- BlockRead(f,(pbyte(@f)+sizeof(FileRec))^,1)
|
|
|
+ BlockRead(f,(pbyte(@f)+sizeof(FileRec))^,1);
|
|
|
End;
|
|
|
|
|
|
|
|
|
Procedure Put(var f:TypedFile);[IOCheck];
|
|
|
begin
|
|
|
- BlockWrite(f,(pbyte(@f)+sizeof(FileRec))^,1)
|
|
|
+ BlockWrite(f,(pbyte(@f)+sizeof(FileRec))^,1);
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -208,6 +222,74 @@ unit iso7185;
|
|
|
Eof:=FileRec(f)._private[1]=1;
|
|
|
End;
|
|
|
|
|
|
+
|
|
|
+ Procedure Seek(var f:TypedFile;Pos:Int64);[IOCheck];
|
|
|
+ Begin
|
|
|
+ System.Seek(f,Pos);
|
|
|
+ if (FileRec(f).mode=fmInOut) or
|
|
|
+ (FileRec(f).mode=fmInput) then
|
|
|
+ begin
|
|
|
+ if FilePos(f)<FileSize(f) then
|
|
|
+ begin
|
|
|
+ FileRec(f)._private[1]:=0;
|
|
|
+ Get(f);
|
|
|
+ end
|
|
|
+ else
|
|
|
+ FileRec(f)._private[1]:=1;
|
|
|
+ end;
|
|
|
+ End;
|
|
|
+
|
|
|
+
|
|
|
+ Function FilePos(var f:TypedFile):Int64;[IOCheck];
|
|
|
+ Begin
|
|
|
+ FilePos:=System.FilePos(f);
|
|
|
+ { in case of reading a file, the buffer is always filled, so the result of Do_FilePos is off by one }
|
|
|
+ if (FileRec(f).mode=fmInOut) or
|
|
|
+ (FileRec(f).mode=fmInput) then
|
|
|
+ dec(FilePos);
|
|
|
+ End;
|
|
|
+
|
|
|
+
|
|
|
+{$ifdef FPC_CURRENCY_IS_INT64}
|
|
|
+{$ifndef FPUNONE}
|
|
|
+ function round(c : currency) : int64;
|
|
|
+ begin
|
|
|
+ if c>=0.0 then
|
|
|
+ Round:=Trunc(c+0.5)
|
|
|
+ else
|
|
|
+ Round:=Trunc(c-0.5);
|
|
|
+ end;
|
|
|
+{$endif FPUNONE}
|
|
|
+
|
|
|
+
|
|
|
+{$ifndef cpujvm}
|
|
|
+ function round(c : comp) : int64;
|
|
|
+ begin
|
|
|
+ if c>=0.0 then
|
|
|
+ round:=Trunc(c+0.5)
|
|
|
+ else
|
|
|
+ round:=Trunc(c-0.5);
|
|
|
+ end;
|
|
|
+{$else not cpujvm}
|
|
|
+ function round_comp(c : comp) : int64;
|
|
|
+ begin
|
|
|
+ if c>=0.0 then
|
|
|
+ round_comp:=Trunc(c+0.5)
|
|
|
+ else
|
|
|
+ round_comp:=Trunc(c-0.5);
|
|
|
+ end;
|
|
|
+{$endif cpujvm}
|
|
|
+{$endif FPC_CURRENCY_IS_INT64}
|
|
|
+
|
|
|
+
|
|
|
+ function Round(d : ValReal) : int64;
|
|
|
+ begin
|
|
|
+ if d>=0.0 then
|
|
|
+ Round:=Trunc(d+0.5)
|
|
|
+ else
|
|
|
+ Round:=Trunc(d-0.5);
|
|
|
+ end;
|
|
|
+
|
|
|
begin
|
|
|
{ we shouldn't do this because it might confuse user programs, but for now it
|
|
|
is good enough to get pretty unique tmp file names }
|