[Overview][Constants][Types][Procedures and functions] |
Read destination of symbolic link
Source position: line 0
function fpReadLink( |
name: pchar; |
linkname: pchar; |
maxlen: size_t |
):cInt; |
Name: ansistring |
):ansistring; |
FpReadLinkreturns the file the symbolic link nameis pointing to. The first form of this function accepts a buffer linknameof length maxlenwhere 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 FpGetErrnofunction.
|
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.