// 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
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.
Copy constructor (copy semantics).
Assignment (copy semantics).
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.
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.
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
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.
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
The system command mv is used instead of the library function rename to be able to move across file systems.
Return the size of the file. If the file does not exist, an exception will be thrown.