[Overview][Constants][Types][Procedures and functions][Index] |
Read destination of symbolic link
Source position: bunxh.inc line 102
function fpReadLink( |
name: PChar; |
linkname: PChar; |
maxlen: size_t |
):cint; |
const Name: RawByteString |
FpReadLink returns the file the symbolic link name is pointing to. The first form of this function accepts a buffer linkname of length maxlen where the filename will be stored. It returns the actual number of characters stored in the buffer.
The second form of the function returns simply the name of the file.
On error, the first form of the function returns -1; the second one returns an empty string. Extended error information is returned by the FpGetErrno function.
|
Create a symbolic link |
Program Example62; { Program to demonstrate the ReadLink function. } Uses BaseUnix,Unix; 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 fpSymLink ('test.txt','new.txt')<>0 then writeln ('Error when symlinking !'); S:=fpReadLink('new.txt'); If S='' then Writeln ('Error reading link !') Else Writeln ('Link points to : ',S); { Now remove links } If fpUnlink ('new.txt')<>0 then Writeln ('Error when unlinking !'); If fpUnlink ('test.txt')<>0 then Writeln ('Error when unlinking !'); end.