casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::RegularFile Class Reference

Manipulate and get information about regular files. More...

#include <RegularFile.h>

Inheritance diagram for casacore::RegularFile:
casacore::File

Public Member Functions

 RegularFile ()
 Default constructor sets path to. More...
 
 RegularFile (const Path &path)
 Create a regular file object for a file with the given path name. More...
 
 RegularFile (const String &string)
 
 RegularFile (const File &file)
 
 RegularFile (const RegularFile &regularFile)
 Copy constructor (copy semantics). More...
 
 ~RegularFile ()
 
RegularFileoperator= (const RegularFile &regularFile)
 Assignment (copy semantics). More...
 
void create (Bool overwrite=True)
 Create the regular file. More...
 
void remove ()
 Remove the file. More...
 
void copy (const Path &target, Bool overwrite=True, Bool setUserWritePermission=True) const
 Copy the file to the target path using the system command cp. More...
 
void copy (const String &target, Bool overwrite=True, Bool setUserWritePermission=True) const
 
void move (const Path &target, Bool overwrite=True)
 Move the file to the target path using the system command mv. More...
 
void move (const String &target, Bool overwrite=True)
 
virtual Int64 size () const
 Return the size of the file. 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 ()
 
Fileoperator= (const File &that)
 Assignment (copy semantics). More...
 
const Pathpath () 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...
 
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...
 

Static Public Member Functions

static void manualCopy (const String &source, const String &target)
 Copy the file manually in case the cp command cannot be used. More...
 
- 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...
 

Private Member Functions

void checkPath ()
 Check if the path of the file is valid. More...
 

Private Attributes

File itsFile
 This variable is used when a symbolic link points to the file. More...
 

Additional Inherited Members

- Public Types inherited from casacore::File
enum  FileWriteStatus {
  OVERWRITABLE,
  NOT_OVERWRITABLE,
  CREATABLE,
  NOT_CREATABLE
}
 
- 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...
 

Detailed Description

Manipulate and get information about regular files.

Review Status

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

Intended use:

Public interface

Prerequisite

Etymology

The class RegularFile provides functions for manipulating and getting information about regular files. Regular file are files which hold data.

Synopsis

This class provides functions to manipulate and to get information about regular files. The functions for getting information (like ownership, dates) about regular files are inherited from the File class.
The class RegularFile itself provides functions to rename, remove, copy, and move regular files. The file name can be a symbolic link resolving (eventually) to a regular file.

Example

// Create the object rFile
RegularFile rFile ("isFile");
// Create file; if the file exists it will be overwritten
rFile.create (True);
rFile.copy (newPath);
cout << rFile.size() << endl; // Get the size of the file
cout << rFile.path() << endl; // Show the relative pathname
rFile.remove(); // remove the file

Motivation

Provide functions for manipulating and getting information about regular files.

Definition at line 91 of file RegularFile.h.

Constructor & Destructor Documentation

casacore::RegularFile::RegularFile ( )

Default constructor sets path to.

(working directory).

casacore::RegularFile::RegularFile ( const Path path)

Create a regular file object for a file with the given path name.

An exception is thrown if the file is illegal, i.e. if it does not exist as a regular file or symbolic link or if cannot be created. Note that the file is not created if it does not exist yet. This can be done using the function create.
When the given path name is a symbolic link, the symbolic link is resolved (recursively) and the resulting file name is used instead.

casacore::RegularFile::RegularFile ( const String string)
casacore::RegularFile::RegularFile ( const File file)
casacore::RegularFile::RegularFile ( const RegularFile regularFile)

Copy constructor (copy semantics).

casacore::RegularFile::~RegularFile ( )

Member Function Documentation

void casacore::RegularFile::checkPath ( )
private

Check if the path of the file is valid.

Also resolve possible symlinks.

void casacore::RegularFile::copy ( const Path target,
Bool  overwrite = True,
Bool  setUserWritePermission = True 
) const

Copy the file to the target path using the system command cp.

If the file is a symbolic link, the regular file pointed to will be copied. 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
Caution: When a readonly file is copied, the resulting file is also readonly; Therefore chmod is used to set user write permission after the copy; The flag setUserWritePermission can be set to False when that should not be done;

Referenced by copy().

void casacore::RegularFile::copy ( const String target,
Bool  overwrite = True,
Bool  setUserWritePermission = True 
) const
inline

Definition at line 190 of file RegularFile.h.

References copy().

void casacore::RegularFile::create ( Bool  overwrite = True)

Create the regular file.


If the file exists and is not a regular file, an exception is thrown. Otherwise if overwrite is true the regular file will be overwritten. If overwrite is false then nothing will be done. If the file does not exist, it is created.

static void casacore::RegularFile::manualCopy ( const String source,
const String target 
)
static

Copy the file manually in case the cp command cannot be used.

(like on the Cray XT3).

void casacore::RegularFile::move ( const Path target,
Bool  overwrite = True 
)

Move the file to the target path using the system command mv.

If the file is a symbolic link, the regular file pointed to will be moved. 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
Tip: The system command mv is used instead of the library function rename to be able to move across file systems;

Referenced by move().

void casacore::RegularFile::move ( const String target,
Bool  overwrite = True 
)
inline

Definition at line 195 of file RegularFile.h.

References move().

RegularFile& casacore::RegularFile::operator= ( const RegularFile regularFile)

Assignment (copy semantics).

void casacore::RegularFile::remove ( )

Remove the file.

If it does not exist, an exception will be thrown. If a symbolic link is given, the link chain pointing to the file will also be removed.

Referenced by casa::SynthesisNormalizerMixin< T >::setup_normalizer().

virtual Int64 casacore::RegularFile::size ( ) const
virtual

Return the size of the file.

If the file does not exist, an exception will be thrown.

Reimplemented from casacore::File.

Member Data Documentation

File casacore::RegularFile::itsFile
private

This variable is used when a symbolic link points to the file.

Definition at line 186 of file RegularFile.h.


The documentation for this class was generated from the following file: