SymLink symLink1("isLink"); SymLink symLink2("isLink2"); SymLink symLinkA("A"); SymLink symLinkB("B"); symLink1.create("~", True); // Create a symbolic link to the home // directory. When it exists it will be // overwritten. symLink2.create("isLink", False); // Create a symbolic link to // isLink. When it exists it will not // be overwritten. symLinkA.create(Path("B")); // Create a recursive link symLinkB.create(Path("A")); // Create a recursive link cout << symLink1.readSymLink() << endl; // The homedirectory is printed cout << symLink2.readSymLink() << endl; // isLink is printed cout << symLink2.followSymLink() << endl;// The homedirectory is printed cout << symLinkA.readSymLink() << endl; // B is printed cout << symLinkA.followSymLink() << endl;// An exception is thrown (loop)
Create a SymLink with the given path. An exception is thrown if the path exist and is no symbolic link or if it does not exist, but cannot be created.
Copy constructor (copy semantics).
Assignment (copy semantics).
Make a symbolic link to a file given by target.
An exception will be thrown if:
-target already exists and is no symlink
-or target already exists and overwrite==False
Copy the symlink to the target path using the system command cp.
The target path can be a directory or a file (as in cp).
An exception is thrown if:
- the target directory is not writable
- or the target file already exists and overwrite==False
- or the target file already exists and is not writable
Move the symlink to the target path using the system command mv.
The target path can be a directory or a file (as in mv).
An exception is thrown if:
- the target directory is not writable
- or the target file already exists and overwrite==False
- or the target file already exists and is not writable
Remove a symbolic link.
Read value of a symbolic link and return it as a Path. If the symlink does not exist, an exception will be thrown. When the symlink points to a file with a relative name, the resulting file name gets prepended by the dirname of the symlink, which is similar to the way a shell handles symlinks. E.g.
ls > subdir/a ln -s a subdir/b more subdir/bThe more command shows the results of subdir/a.
As readSymLink, but the entire symlink chain is followed when the symlinks points to other symlinks. An exception is thrown if this results in a loop (that is, if more than 25 links are encountered).
Get the value of the symlink.