casacore
|
#include <SymLink.h>
Public Member Functions | |
SymLink () | |
The default constructor creates a SymLink with path ".". More... | |
SymLink (const Path &name) | |
Create a SymLink with the given path. More... | |
SymLink (const String &name) | |
SymLink (const File &name) | |
SymLink (const SymLink &that) | |
Copy constructor (copy semantics). More... | |
~SymLink () | |
SymLink & | operator= (const SymLink &that) |
Assignment (copy semantics). More... | |
void | create (const Path &target, Bool overwrite=True) |
Make a symbolic link to a file given by target. More... | |
void | create (const String &target, Bool overwrite=True) |
void | copy (const Path &target, Bool overwrite=True) const |
Copy the symlink to the target path using the system command cp. More... | |
void | copy (const String &target, Bool overwrite=True) const |
void | move (const Path &target, Bool overwrite=True) |
Move the symlink to the target path using the system command mv. More... | |
void | move (const String &target, Bool overwrite=True) |
void | remove () |
Remove a symbolic link. More... | |
Path | readSymLink () const |
Read value of a symbolic link and return it as a Path. More... | |
Path | followSymLink () const |
As readSymLink, but the entire symlink chain is followed when the symlinks points to other symlinks. More... | |
Public Member Functions inherited from casacore::File | |
File () | |
Construct a File object whose Path is set to the current working directory. More... | |
File (const Path &path) | |
Construct a File object whose Path is set to the given Path. More... | |
File (const String &path) | |
File (const File &that) | |
Copy constructor (copy semantics). More... | |
virtual | ~File () |
File & | operator= (const File &that) |
Assignment (copy semantics). More... | |
const Path & | path () const |
Returns the pathname of the file. More... | |
Bool | isRegular (Bool followSymLink=True) const |
Check if the file is a regular file. More... | |
Bool | isDirectory (Bool followSymLink=True) const |
Check if the file is a directory. More... | |
Bool | isSymLink () const |
Check if the file is a symbolic link. More... | |
Bool | isPipe () const |
Check if the file is a pipe. More... | |
Bool | isCharacterSpecial () const |
Check if the file is a character special file. More... | |
Bool | isBlockSpecial () const |
Check if the file is a block special file. More... | |
Bool | isSocket () const |
Check if the file is a socket. More... | |
Bool | exists () const |
Check if the file exists. More... | |
Bool | isReadable () const |
Check if the file is readable. More... | |
Bool | isWritable () const |
Check if the file is writable. More... | |
Bool | isExecutable () const |
Check if the file is executable. More... | |
Bool | canCreate () const |
Check if a file can be created. More... | |
long | userID () const |
Return the userID of the file. More... | |
long | groupID () const |
Return the groupID of the file. More... | |
virtual Int64 | size () const |
Return the size of the file. More... | |
uInt | readPermissions () const |
Return the permissions as a decimal value. More... | |
void | setPermissions (uInt permissions) |
Set permission with perm. More... | |
void | touch (uInt time) |
Update access time and modification time of a file. More... | |
void | touch () |
Update access time and modification time of a file. More... | |
uInt | accessTime () const |
Time related fucnctions: Return the time when the file was last accessed in seconds since 00:00:00 GMT Jan 1, 1970. More... | |
String | accessTimeString () const |
Return the time when the file was last accessed as a 26-characters String of the form: Thu Feb 3 13:40:11 1994. More... | |
uInt | modifyTime () const |
Return the time when the file was last modified in seconds since 00:00:00 GMT Jan 1, 1970. More... | |
String | modifyTimeString () const |
Return the time when the file was last modified as a 26-characters String of the form: Thu Feb 3 13:40:11 1994. More... | |
uInt | statusChangeTime () const |
Return the time when the file status was last changed in seconds since 00:00:00 GMT Jan 1, 1970. More... | |
String | statusChangeTimeString () const |
return the time when the file status was last changed as a 26-characters String of the form: Thu Feb 3 13:40:11 1994 More... | |
FileWriteStatus | getWriteStatus () const |
get write status of the file. More... | |
String | getFSType () const |
Return the filesystem type. More... | |
Private Member Functions | |
void | checkPath () const |
Check if the path of the file is valid. More... | |
String | getSymLink () const |
Get the value of the symlink. More... | |
Additional Inherited Members | |
Public Types inherited from casacore::File | |
enum | FileWriteStatus { OVERWRITABLE , NOT_OVERWRITABLE , CREATABLE , NOT_CREATABLE } |
Static Public Member Functions inherited from casacore::File | |
static Path | newUniqueName (const String &directory, const String &prefix) |
Create a new unique path name in the specified directory, with the specified prefix and random trailing characters: More... | |
static Path | newUniqueName (const String &directory) |
Create a new unique filename without a prefix. More... | |
Protected Member Functions inherited from casacore::File | |
void | removeSymLinks () |
This function is used by RegularFile and Directory to remove all the links which, when followed, ultimately resolve to a Directory or a RegularFile. More... | |
void | checkTarget (Path &targetName, Bool overwrite, Bool forDirectory=False) const |
Check if the new path for a copy or move is valid. More... | |
Get information about, and manipulate symbolic links
Public interface
The class SymLink handles SYMbolic LINKs in the file system.
SymLink provides functions to manipulate and to get information about symbolic links. The functions for getting information (like ownership, dates) about symbolic links are inherited from the File class.
The class SymLink itself provides functions to create, remove, copy, and move symbolic links. There is a function readSymLink which reads a link and then returns a path and there is a function followSymLink which reads a link recursively. If the link eventually refers to itself (a loop), an exception will be thrown.
Provide functions for manipulating and getting information about symbolic links.
casacore::SymLink::SymLink | ( | ) |
The default constructor creates a SymLink with path ".".
casacore::SymLink::SymLink | ( | const Path & | name | ) |
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.
casacore::SymLink::SymLink | ( | const String & | name | ) |
casacore::SymLink::SymLink | ( | const File & | name | ) |
casacore::SymLink::SymLink | ( | const SymLink & | that | ) |
Copy constructor (copy semantics).
casacore::SymLink::~SymLink | ( | ) |
|
private |
Check if the path of the file is valid.
Also resolve possible symlinks.
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
Referenced by copy().
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
Referenced by create().
Path casacore::SymLink::followSymLink | ( | ) | const |
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).
|
private |
Get the value of the symlink.
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
Referenced by move().
Path casacore::SymLink::readSymLink | ( | ) | const |
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.
The more command shows the results of subdir/a.
void casacore::SymLink::remove | ( | ) |
Remove a symbolic link.