|
@@ -2,44 +2,44 @@ Program Example20;
|
|
|
|
|
|
{ Program to demonstrate the fdRead and fdTruncate functions. }
|
|
{ Program to demonstrate the fdRead and fdTruncate functions. }
|
|
|
|
|
|
-Uses linux;
|
|
|
|
|
|
+Uses BaseUnix;
|
|
|
|
|
|
-Const Data : string[10] = '12345687890';
|
|
|
|
|
|
+Const Data : string[10] = '1234567890';
|
|
|
|
|
|
-Var FD : Longint;
|
|
|
|
|
|
+Var FD : cint;
|
|
l : longint;
|
|
l : longint;
|
|
|
|
|
|
begin
|
|
begin
|
|
- FD:=fdOpen('test.dat',open_wronly or open_creat,octal(666));
|
|
|
|
|
|
+ FD:=fpOpen('test.dat',o_wronly or o_creat,&666);
|
|
if fd>0 then
|
|
if fd>0 then
|
|
begin
|
|
begin
|
|
{ Fill file with data }
|
|
{ Fill file with data }
|
|
for l:=1 to 10 do
|
|
for l:=1 to 10 do
|
|
- if fdWrite (FD,Data[1],10)<>10 then
|
|
|
|
|
|
+ if fpWrite (FD,Data[1],10)<>10 then
|
|
begin
|
|
begin
|
|
writeln ('Error when writing !');
|
|
writeln ('Error when writing !');
|
|
halt(1);
|
|
halt(1);
|
|
end;
|
|
end;
|
|
- fdClose(FD);
|
|
|
|
- FD:=fdOpen('test.dat',open_rdonly);
|
|
|
|
|
|
+ fpClose(FD);
|
|
|
|
+ FD:=fpOpen('test.dat',o_rdonly);
|
|
{ Read data again }
|
|
{ Read data again }
|
|
If FD>0 then
|
|
If FD>0 then
|
|
begin
|
|
begin
|
|
For l:=1 to 5 do
|
|
For l:=1 to 5 do
|
|
- if fdRead (FD,Data[1],10)<>10 then
|
|
|
|
|
|
+ if fpRead (FD,Data[1],10)<>10 then
|
|
begin
|
|
begin
|
|
Writeln ('Error when Reading !');
|
|
Writeln ('Error when Reading !');
|
|
Halt(2);
|
|
Halt(2);
|
|
end;
|
|
end;
|
|
- fdCLose(FD);
|
|
|
|
|
|
+ fpClose(FD);
|
|
{ Truncating file at 60 bytes }
|
|
{ Truncating file at 60 bytes }
|
|
{ For truncating, file must be open or write }
|
|
{ For truncating, file must be open or write }
|
|
- FD:=fdOpen('test.dat',open_wronly,octal(666));
|
|
|
|
|
|
+ FD:=fpOpen('test.dat',o_wronly,&666);
|
|
if FD>0 then
|
|
if FD>0 then
|
|
begin
|
|
begin
|
|
- if not fdTruncate(FD,60) then
|
|
|
|
|
|
+ if fpfTruncate(FD,60)<>0 then
|
|
Writeln('Error when truncating !');
|
|
Writeln('Error when truncating !');
|
|
- fdClose (FD);
|
|
|
|
|
|
+ fpClose (FD);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|