#include <BALL/SYSTEM/file.h>
File Class.
Definition at line 134 of file file.h.
◆ OpenMode
File open modes. This type is used to describe the standard openmodes for files as described in Section 27.4.2.1.4 of the ANSI C++ standard.
Definition at line 165 of file file.h.
◆ Transformation
Transformation types for file. This enum defines some possible types for on-the-fly file transformation.
Enumerator |
---|
TRANSFORMATION__EXEC | |
TRANSFORMATION__FILTER | |
TRANSFORMATION__URL | |
Definition at line 198 of file file.h.
◆ Type
Filetype
Enumerator |
---|
TYPE__UNKNOWN | |
TYPE__DIRECTORY | |
TYPE__CHAR_SPECIAL_FILE | |
TYPE__BLOCK_SPECIAL_FILE | |
TYPE__REGULAR_FILE | |
TYPE__SYMBOLIC_LINK | |
TYPE__SOCKET | |
TYPE__FIFO_SPECIAL_FILE | |
Definition at line 210 of file file.h.
◆ File() [1/2]
◆ File() [2/2]
BALL::File::File |
( |
const String & |
name, |
|
|
OpenMode |
open_mode = std::ios::in |
|
) |
| |
Construct new File object from the file name and open the file.
- Parameters
-
name | the name of the file to be opened |
open_mode | the openmode to be used |
- See also
- open
- Exceptions
-
◆ ~File()
virtual BALL::File::~File |
( |
| ) |
|
|
virtual |
Destructor. The file is closed.
◆ clear()
virtual void BALL::File::clear |
( |
| ) |
|
|
virtual |
Clear the File object.
Reimplemented in BALL::TRRFile, BALL::TrajectoryFile, BALL::ResourceFile, BALL::PDBFile, BALL::NMRStarFile, BALL::MOPACOutputFile, BALL::LineBasedFile, BALL::HMOFile, BALL::DSN6File, BALL::DCDFile, BALL::CCP4File, and BALL::AmiraMeshFile.
◆ close()
void BALL::File::close |
( |
| ) |
|
◆ copy()
static bool BALL::File::copy |
( |
String |
source_name, |
|
|
String |
destination_name, |
|
|
Size |
buffer_size = 4096 |
|
) |
| |
|
static |
Copy a given file to a given destination. If a file with the destination name exists already, nothing happens.
- Parameters
-
source_name | the name of the source file |
destination_name | the name of the destination file |
buffer_size | the buffer size to use while copying |
- Returns
- true if copying was successfull
- Exceptions
-
◆ copyTo()
bool BALL::File::copyTo |
( |
const String & |
destination_name, |
|
|
Size |
buffer_size = 4096 |
|
) |
| |
Copy the file to a given destination. If a file with the destination name exists already, nothing happens.
- Parameters
-
destination_name | the name of the destination file |
buffer_size | the buffer size to use while copying |
- Returns
- true if copying was successfull
- Exceptions
-
◆ createTemporaryFilename()
static bool BALL::File::createTemporaryFilename |
( |
String & |
temporary, |
|
|
const String & |
suffix = ".TMP" |
|
) |
| |
|
static |
Create a temporary filename. This method creates strings, starting at _AAAAAAA, adds the suffix /suffix/ which defaults to .TMP and tries if a file with this name exists. If not, the string is returned. If a file with this name exists, it continues to create names up to _ZZZZZZZ.
- Parameters
-
temporary | reference to the temporary filename |
- Returns
- bool true if a temporary filename could be found
◆ disableTransformation()
static void BALL::File::disableTransformation |
( |
Transformation |
transformation | ) |
|
|
static |
◆ enableTransformation()
static void BALL::File::enableTransformation |
( |
Transformation |
transformation | ) |
|
|
static |
◆ getFileStream()
std::fstream& BALL::File::getFileStream |
( |
| ) |
|
Return the stream associated with this file. Implemented just for convenience.
- Returns
- std::fstream the stream
◆ getName()
const String& BALL::File::getName |
( |
| ) |
const |
Return the name of the file.
- Returns
- String the name of the file
◆ getOpenMode()
Return the open mode. Default is IN.
- Returns
- int the open mode
◆ getOriginalName()
const String& BALL::File::getOriginalName |
( |
| ) |
const |
◆ getSize() [1/2]
Size BALL::File::getSize |
( |
| ) |
|
Return the size of the file. If the file does not exist, 0 is returned.
- Returns
- Size the size of the file
- Exceptions
-
◆ getSize() [2/2]
Return the size of a given file.
- Returns
- Size the size of the file
- Exceptions
-
◆ getTransformationManager() [1/2]
◆ getTransformationManager() [2/2]
◆ getType() [1/2]
Type BALL::File::getType |
( |
bool |
trace_link | ) |
const |
Return the filetype.
- Parameters
-
trace_link | true to follow links |
- Returns
- Type the filetype
- Exceptions
-
◆ getType() [2/2]
Return the filetype of a given file.
- Parameters
-
name | the name of the file. |
trace_link | true to follow links |
- Returns
- Type the filetype
- Exceptions
-
◆ isAccessible() [1/2]
bool BALL::File::isAccessible |
( |
| ) |
const |
Test if the file can be accessed.
- Returns
- bool true if the file can be accessed
- Exceptions
-
Exception::FileNotfound | if the file could not be found |
◆ isAccessible() [2/2]
static bool BALL::File::isAccessible |
( |
String |
name | ) |
|
|
static |
Test if a given file can be accessed.
- Parameters
-
name | the name of the file to be tested |
- Returns
- bool true if the file can be accessed
◆ isCanonized()
bool BALL::File::isCanonized |
( |
| ) |
const |
Test if the path of the file is canonized. The path is compared before and after call of FileSystem::canonizePath(canonized_name).
- See also
- FileSystem::canonizePath
- Returns
- bool true if the path is canonized.
- Exceptions
-
Exception::FileNotfound | if the file could not be found |
◆ isClosed()
bool BALL::File::isClosed |
( |
| ) |
const |
Test if the file is closed. The standard constructor opens the file.
- Returns
- bool true if the file is closed
◆ isExecutable() [1/2]
bool BALL::File::isExecutable |
( |
| ) |
const |
Test if the file is executable.
- Returns
- true if the file is executable
- Exceptions
-
Exception::FileNotfound | if the file could not be found |
◆ isExecutable() [2/2]
static bool BALL::File::isExecutable |
( |
String |
name | ) |
|
|
static |
Test if a given file is executable.
- Parameters
-
- Returns
- true if the file is executable
- Exceptions
-
Exception::FileNotfound | if the file could not be found |
◆ isOpen()
bool BALL::File::isOpen |
( |
| ) |
const |
Test if the file is opend. The standard constructor opens the file.
- Returns
- bool true if the file is closed
◆ isReadable() [1/2]
bool BALL::File::isReadable |
( |
| ) |
const |
Test if the file is readable.
- Returns
- true if the file can be read
- Exceptions
-
Exception::FileNotfound | if the file could not be found |
◆ isReadable() [2/2]
Test if a given file is readable.
- Parameters
-
- Returns
- true if the file can be read
- Exceptions
-
Exception::FileNotfound | if the file could not be found |
◆ isTransformationEnabled()
◆ isValid()
bool BALL::File::isValid |
( |
| ) |
const |
Test if the file is valid. If the filename was not set, false is returned. This function uses std::fstream::good().
- Returns
- bool true if the file is valid
◆ isWritable() [1/2]
bool BALL::File::isWritable |
( |
| ) |
const |
Test if the file is writeable.
- Returns
- true if the file is writeable
- Exceptions
-
Exception::FileNotfound | if the file could not be found |
◆ isWritable() [2/2]
Test if a given file is writeable.
- Parameters
-
- Returns
- true if the file is writeable
- Exceptions
-
Exception::FileNotfound | if the file could not be found |
◆ move()
static bool BALL::File::move |
( |
const String & |
source_name, |
|
|
const String & |
destination_name |
|
) |
| |
|
static |
Move a given file to a given destination. If a file with the destination name exists already, nothing happens.
- Parameters
-
source_name | the name of the source file |
destination_name | the name of the destination file |
- Returns
- true if copying was successfull
- Exceptions
-
◆ moveTo()
bool BALL::File::moveTo |
( |
const String & |
destination_name | ) |
|
Move the file to a given destination. If a file with the destination name exists already, nothing happens.
- Parameters
-
destination_name | the name of the destination file |
- Returns
- true if copying was successfull
- Exceptions
-
◆ open()
Open a given file. The standard constructor uses this method.
- Parameters
-
name | the name of the file |
open_mode | the open mode, default is IN |
- Returns
- bool true if the file could be opened
- Exceptions
-
◆ operator!=()
bool BALL::File::operator!= |
( |
const File & |
file | ) |
const |
Inequality comparison operator. Two File objects are inequal if they point not to the same canonized filename.
◆ operator==()
bool BALL::File::operator== |
( |
const File & |
file | ) |
const |
Equality comparison operator. Two File objects are equal if they point to the same canonized filename.
◆ registerTransformation()
static void BALL::File::registerTransformation |
( |
const String & |
pattern, |
|
|
const String & |
exec |
|
) |
| |
|
static |
◆ remove() [1/2]
bool BALL::File::remove |
( |
| ) |
|
Remove the file.
- Returns
- bool true if the file could be removed
◆ remove() [2/2]
Remove the given file.
- Parameters
-
name | the name of the file to be removed |
- Returns
- bool true if the file could be removed
◆ rename()
Rename a file.
- Parameters
-
old_path | the path and name of the file to be renamed |
new_path | the new path and name of the file |
- Returns
- bool true if the file could be renamed
- Exceptions
-
◆ renameTo()
bool BALL::File::renameTo |
( |
const String & |
new_path | ) |
|
Rename the file to a given name. If a file with the destination name exists already, nothing happens.
- Parameters
-
new_path | the new path and name of the file |
- Returns
- bool true if the file could be renamed
- Exceptions
-
◆ reopen() [1/2]
bool BALL::File::reopen |
( |
| ) |
|
Reopen the file. The file is closed and reopend.
- Returns
- bool true if the file could be reopened
- Exceptions
-
◆ reopen() [2/2]
Reopen the file with a different mode. The file is closed and reopend.
- Parameters
-
- Returns
- bool true if the file could be reopend
- Exceptions
-
◆ setName()
void BALL::File::setName |
( |
const String & |
name | ) |
|
Close the file and point to an other file.
- Parameters
-
◆ truncate() [1/2]
bool BALL::File::truncate |
( |
Size |
size = 0 | ) |
|
Truncate the file.
- Parameters
-
size | the new size of the file |
- Returns
- bool true if the file could be truncated
- Exceptions
-
◆ truncate() [2/2]
Truncate a given file.
- Parameters
-
path | the path to the file |
size | the new size of the file |
- Returns
- bool true if the file could be truncated
- Exceptions
-
◆ unregisterTransformation()
static void BALL::File::unregisterTransformation |
( |
const String & |
pattern | ) |
|
|
static |
◆ created_temp_filenames_
◆ is_open_
bool BALL::File::is_open_ |
|
protected |
◆ is_temporary_
bool BALL::File::is_temporary_ |
|
protected |
◆ MODE_APP
Append. Seek to end before each write operation.
Definition at line 179 of file file.h.
◆ MODE_ATE
Seek to end directly after opening.
Definition at line 185 of file file.h.
◆ MODE_BINARY
Binary mode.
Definition at line 182 of file file.h.
◆ MODE_IN
Open for input (default)
Definition at line 173 of file file.h.
◆ MODE_OUT
Open for output.
Definition at line 176 of file file.h.
◆ MODE_TRUNC
Truncate an existing file.
Definition at line 188 of file file.h.
◆ name_
◆ open_mode_
◆ original_name_
String BALL::File::original_name_ |
|
protected |
◆ TRANSFORMATION_EXEC_PREFIX
const String BALL::File::TRANSFORMATION_EXEC_PREFIX |
|
static |
Prefix for filenames that are created through the execution of commands "exec:".
Definition at line 231 of file file.h.
◆ TRANSFORMATION_FILE_PREFIX
const String BALL::File::TRANSFORMATION_FILE_PREFIX |
|
static |
Prefix for files (to mimick URL-like behavior) "file:".
Definition at line 234 of file file.h.
◆ TRANSFORMATION_FTP_PREFIX
const String BALL::File::TRANSFORMATION_FTP_PREFIX |
|
static |
Prefix for FTP-transfers "ftp://".
Definition at line 237 of file file.h.
◆ TRANSFORMATION_HTTP_PREFIX
const String BALL::File::TRANSFORMATION_HTTP_PREFIX |
|
static |
Prefix for HTTP-transfer "http://".
Definition at line 240 of file file.h.
◆ transformation_manager_
◆ transformation_methods_
Size BALL::File::transformation_methods_ |
|
staticprotected |