Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1SymLink.html
Дата изменения: Unknown
Дата индексирования: Mon Feb 14 20:55:28 2011
Кодировка:

Поисковые слова: http www.starlab.ru showthread.php p 145434
casacore: casa::SymLink Class Reference
Public Member Functions | Private Member Functions

casa::SymLink Class Reference
[OS_module]

Get information about, and manipulate symbolic links. More...

#include <SymLink.h>

Inheritance diagram for casa::SymLink:
casa::File

List of all members.

Public Member Functions

 SymLink ()
 The default constructor creates a SymLink with path ".".
 SymLink (const Path &name)
 Create a SymLink with the given path.
 SymLink (const String &name)
 SymLink (const File &name)
 SymLink (const SymLink &that)
 Copy constructor (copy semantics).
 ~SymLink ()
SymLinkoperator= (const SymLink &that)
 Assignment (copy semantics).
void create (const Path &target, Bool overwrite=True)
 Make a symbolic link to a file given by target.
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.
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.
void move (const String &target, Bool overwrite=True)
void remove ()
 Remove a symbolic link.
Path readSymLink () const
 Read value of a symbolic link and return it as a Path.
Path followSymLink () const
 As readSymLink, but the entire symlink chain is followed when the symlinks points to other symlinks.

Private Member Functions

void checkPath () const
 Check if the path of the file is valid.
String getSymLink () const
 Get the value of the symlink.

Detailed Description

Get information about, and manipulate symbolic links.

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Intended use:

Public interface

Prerequisite

Etymology

The class SymLink handles SYMbolic LINKs in the file system.

Synopsis

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.

Example

       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)

Motivation

Provide functions for manipulating and getting information about symbolic links.

Definition at line 100 of file SymLink.h.


Constructor & Destructor Documentation

casa::SymLink::SymLink (  ) 

The default constructor creates a SymLink with path ".".

casa::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.

casa::SymLink::SymLink ( const String name  ) 
casa::SymLink::SymLink ( const File name  ) 
casa::SymLink::SymLink ( const SymLink that  ) 

Copy constructor (copy semantics).

casa::SymLink::~SymLink (  ) 

Member Function Documentation

void casa::SymLink::checkPath (  )  const [private]

Check if the path of the file is valid.

Also resolve possible symlinks.

void casa::SymLink::copy ( const Path target,
Bool  overwrite = True 
) const

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().

void casa::SymLink::copy ( const String target,
Bool  overwrite = True 
) const [inline]

Definition at line 192 of file SymLink.h.

References copy().

void casa::SymLink::create ( const Path target,
Bool  overwrite = True 
)

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().

void casa::SymLink::create ( const String target,
Bool  overwrite = True 
) [inline]

Definition at line 188 of file SymLink.h.

References create().

Path casa::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).

String casa::SymLink::getSymLink (  )  const [private]

Get the value of the symlink.

void casa::SymLink::move ( const Path target,
Bool  overwrite = True 
)

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().

void casa::SymLink::move ( const String target,
Bool  overwrite = True 
) [inline]

Definition at line 196 of file SymLink.h.

References move().

SymLink& casa::SymLink::operator= ( const SymLink that  ) 

Assignment (copy semantics).

Path casa::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.

         ls > subdir/a
         ln -s a subdir/b
         more subdir/b

The more command shows the results of subdir/a.

void casa::SymLink::remove (  ) 

Remove a symbolic link.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines