mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 12:40:25 +02:00
* 1.9.x updates
This commit is contained in:
parent
92ed8c2f77
commit
fe840931ad
@ -2,18 +2,18 @@ Program Example19;
|
|||||||
|
|
||||||
{ Program to demonstrate the fdOpen, fdwrite and fdCLose functions. }
|
{ Program to demonstrate the fdOpen, fdwrite and fdCLose functions. }
|
||||||
|
|
||||||
Uses linux;
|
Uses BaseUnix;
|
||||||
|
|
||||||
Const Line : String[80] = 'This is easy writing !';
|
Const Line : String[80] = 'This is easy writing !';
|
||||||
|
|
||||||
Var FD : Longint;
|
Var FD : Cint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FD:=fdOpen ('Test.dat',Open_WrOnly or Open_Creat);
|
FD:=fpOpen ('Test.dat',O_WrOnly or O_Creat);
|
||||||
if FD>0 then
|
if FD>0 then
|
||||||
begin
|
begin
|
||||||
if length(Line)<>fdwrite (FD,Line[1],Length(Line)) then
|
if length(Line)<>fpwrite (FD,Line[1],Length(Line)) then
|
||||||
Writeln ('Error when writing to file !');
|
Writeln ('Error when writing to file !');
|
||||||
fdClose(FD);
|
fpClose(FD);
|
||||||
end;
|
end;
|
||||||
end.
|
end.
|
||||||
|
@ -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);
|
fpClose(FD);
|
||||||
FD:=fdOpen('test.dat',open_rdonly);
|
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user