mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 23:29:13 +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. }
|
||||
|
||||
Uses linux;
|
||||
Uses BaseUnix;
|
||||
|
||||
Const Line : String[80] = 'This is easy writing !';
|
||||
|
||||
Var FD : Longint;
|
||||
Var FD : Cint;
|
||||
|
||||
begin
|
||||
FD:=fdOpen ('Test.dat',Open_WrOnly or Open_Creat);
|
||||
FD:=fpOpen ('Test.dat',O_WrOnly or O_Creat);
|
||||
if FD>0 then
|
||||
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 !');
|
||||
fdClose(FD);
|
||||
fpClose(FD);
|
||||
end;
|
||||
end.
|
||||
|
@ -2,44 +2,44 @@ Program Example20;
|
||||
|
||||
{ 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;
|
||||
|
||||
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
|
||||
begin
|
||||
{ Fill file with data }
|
||||
for l:=1 to 10 do
|
||||
if fdWrite (FD,Data[1],10)<>10 then
|
||||
if fpWrite (FD,Data[1],10)<>10 then
|
||||
begin
|
||||
writeln ('Error when writing !');
|
||||
halt(1);
|
||||
end;
|
||||
fdClose(FD);
|
||||
FD:=fdOpen('test.dat',open_rdonly);
|
||||
fpClose(FD);
|
||||
FD:=fpOpen('test.dat',o_rdonly);
|
||||
{ Read data again }
|
||||
If FD>0 then
|
||||
begin
|
||||
For l:=1 to 5 do
|
||||
if fdRead (FD,Data[1],10)<>10 then
|
||||
if fpRead (FD,Data[1],10)<>10 then
|
||||
begin
|
||||
Writeln ('Error when Reading !');
|
||||
Halt(2);
|
||||
end;
|
||||
fdCLose(FD);
|
||||
fpClose(FD);
|
||||
{ Truncating file at 60 bytes }
|
||||
{ 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
|
||||
begin
|
||||
if not fdTruncate(FD,60) then
|
||||
if fpfTruncate(FD,60)<>0 then
|
||||
Writeln('Error when truncating !');
|
||||
fdClose (FD);
|
||||
fpClose (FD);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user