mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 08:06:07 +02:00
* 1.9.x updates
This commit is contained in:
parent
fe840931ad
commit
b95908698f
@ -1 +1,31 @@
|
|||||||
:pserver:mazen@cvs.freepascal.org:/FPC/CVS
|
Program Example21;
|
||||||
|
|
||||||
|
{ Program to demonstrate the Link and UnLink functions. }
|
||||||
|
|
||||||
|
Uses BaseUnix;
|
||||||
|
|
||||||
|
Var F : Text;
|
||||||
|
S : String;
|
||||||
|
begin
|
||||||
|
Assign (F,'test.txt');
|
||||||
|
Rewrite (F);
|
||||||
|
Writeln (F,'This is written to test.txt');
|
||||||
|
Close(f);
|
||||||
|
{ new.txt and test.txt are now the same file }
|
||||||
|
if fpLink ('test.txt','new.txt')<>0 then
|
||||||
|
writeln ('Error when linking !');
|
||||||
|
{ Removing test.txt still leaves new.txt }
|
||||||
|
If fpUnlink ('test.txt')<>0 then
|
||||||
|
Writeln ('Error when unlinking !');
|
||||||
|
Assign (f,'new.txt');
|
||||||
|
Reset (F);
|
||||||
|
While not EOF(f) do
|
||||||
|
begin
|
||||||
|
Readln(F,S);
|
||||||
|
Writeln ('> ',s);
|
||||||
|
end;
|
||||||
|
Close (f);
|
||||||
|
{ Remove new.txt also }
|
||||||
|
If not FPUnlink ('new.txt')<>0 then
|
||||||
|
Writeln ('Error when unlinking !');
|
||||||
|
end.
|
||||||
|
@ -2,7 +2,7 @@ Program Example22;
|
|||||||
|
|
||||||
{ Program to demonstrate the SymLink and UnLink functions. }
|
{ Program to demonstrate the SymLink and UnLink functions. }
|
||||||
|
|
||||||
Uses linux;
|
Uses baseunix,Unix;
|
||||||
|
|
||||||
Var F : Text;
|
Var F : Text;
|
||||||
S : String;
|
S : String;
|
||||||
@ -13,11 +13,11 @@ begin
|
|||||||
Writeln (F,'This is written to test.txt');
|
Writeln (F,'This is written to test.txt');
|
||||||
Close(f);
|
Close(f);
|
||||||
{ new.txt and test.txt are now the same file }
|
{ new.txt and test.txt are now the same file }
|
||||||
if not SymLink ('test.txt','new.txt') then
|
if fpSymLink ('test.txt','new.txt')<>0 then
|
||||||
writeln ('Error when symlinking !');
|
writeln ('Error when symlinking !');
|
||||||
{ Removing test.txt still leaves new.txt
|
{ Removing test.txt still leaves new.txt
|
||||||
Pointing now to a non-existent file ! }
|
Pointing now to a non-existent file ! }
|
||||||
If not Unlink ('test.txt') then
|
If fpUnlink ('test.txt')<>0 then
|
||||||
Writeln ('Error when unlinking !');
|
Writeln ('Error when unlinking !');
|
||||||
Assign (f,'new.txt');
|
Assign (f,'new.txt');
|
||||||
{ This should fail, since the symbolic link
|
{ This should fail, since the symbolic link
|
||||||
@ -28,6 +28,6 @@ begin
|
|||||||
If IOResult=0 then
|
If IOResult=0 then
|
||||||
Writeln ('This shouldn''t happen');
|
Writeln ('This shouldn''t happen');
|
||||||
{ Now remove new.txt also }
|
{ Now remove new.txt also }
|
||||||
If not Unlink ('new.txt') then
|
If fpUnlink ('new.txt')<>0 then
|
||||||
Writeln ('Error when unlinking !');
|
Writeln ('Error when unlinking !');
|
||||||
end.
|
end.
|
||||||
|
@ -2,7 +2,7 @@ Program Example23;
|
|||||||
|
|
||||||
{ Program to demonstrate the Chmod function. }
|
{ Program to demonstrate the Chmod function. }
|
||||||
|
|
||||||
Uses linux;
|
Uses BaseUnix,Unix;
|
||||||
|
|
||||||
Var F : Text;
|
Var F : Text;
|
||||||
|
|
||||||
@ -13,9 +13,7 @@ begin
|
|||||||
Writeln (f,'#!/bin/sh');
|
Writeln (f,'#!/bin/sh');
|
||||||
Writeln (f,'echo Some text for this file');
|
Writeln (f,'echo Some text for this file');
|
||||||
Close (F);
|
Close (F);
|
||||||
{ Octal() makes the correct number from a
|
fpChmod ('testex21',&777);
|
||||||
number that LOOKS octal }
|
|
||||||
Chmod ('testex21',octal (777));
|
|
||||||
{ File is now executable }
|
{ File is now executable }
|
||||||
execl ('./testex21');
|
execl ('./testex21');
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user