OpenMS
2.4.0
|
Basic file handling operations. More...
#include <OpenMS/SYSTEM/File.h>
Classes | |
class | TemporaryFiles_ |
Internal helper class, which holds temporary filenames and deletes these files at program exit. More... | |
Static Public Member Functions | |
static String | getExecutablePath () |
static bool | exists (const String &file) |
Method used to test if a file exists. More... | |
static bool | empty (const String &file) |
Return true if the file does not exist or the file is empty. More... | |
static bool | rename (const String &from, const String &to, bool overwrite_existing=true, bool verbose=true) |
Rename a file. More... | |
static bool | remove (const String &file) |
Removes a file (if it exists). More... | |
static bool | removeDirRecursively (const String &dir_name) |
Removes the subdirectories of the specified directory (absolute path). Returns true if successful. More... | |
static bool | removeDir (const QString &dir_name) |
Removes the directory and all subdirectories (absolute path). More... | |
static String | absolutePath (const String &file) |
Replaces the relative path in the argument with the absolute path. More... | |
static String | basename (const String &file) |
Returns the basename of the file (without the path). More... | |
static String | path (const String &file) |
Returns the path of the file (without the file name). More... | |
static String | removeExtension (const String &file) |
static bool | readable (const String &file) |
Return true if the file exists and is readable. More... | |
static bool | writable (const String &file) |
Return true if the file is writable. More... | |
static bool | isDirectory (const String &path) |
Return true if the given path specifies a directory. More... | |
static String | find (const String &filename, StringList directories=StringList()) |
Looks up the location of the file filename . More... | |
static bool | fileList (const String &dir, const String &file_pattern, StringList &output, bool full_path=false) |
Retrieves a list of files matching file_pattern in directory dir (returns filenames without paths unless full_path is true) More... | |
static String | findDoc (const String &filename) |
Resolves a partial file name to a documentation file in the doc-folder. More... | |
static String | getUniqueName (bool include_hostname=true) |
Returns a string, consisting of date, time, hostname, process id, and a incrementing number. This can be used for temporary files. More... | |
static String | getOpenMSDataPath () |
Returns the OpenMS data path (environment variable overwrites the default installation path) More... | |
static String | getOpenMSHomePath () |
Returns the OpenMS home path (environment variable overwrites the default home path) More... | |
static String | getTempDirectory () |
The current OpenMS temporary data path (for temporary files) More... | |
static String | getUserDirectory () |
static Param | getSystemParameters () |
static String | findDatabase (const String &db_name) |
static String | findExecutable (const String &toolName) |
Searches for an executable with the given name. More... | |
static const String & | getTemporaryFile (const String &alternative_file="") |
Obtain a temporary filename, ensuring automatic deletion upon exit. More... | |
Static Private Member Functions | |
static Param | getSystemParameterDefaults_ () |
get defaults for the system's Temp-path, user home directory etc. More... | |
static bool | isOpenMSDataPath_ (const String &path) |
Check if the given path is a valid OPENMS_DATA_PATH. More... | |
Static Private Attributes | |
static TemporaryFiles_ | temporary_files_ |
private list of temporary filenames, which are deleted upon program exit More... | |
Friends | |
class | TOPPBase |
Basic file handling operations.
Replaces the relative path in the argument with the absolute path.
Referenced by TOPPViewBase::addDataFile(), and TOPPViewBase::addRecentFile_().
Returns the basename of the file (without the path).
Referenced by TOPPViewBase::addDataFile(), TOPPASBase::addTOPPASFile(), DTAFile::load(), TOPPASBase::refreshParameters(), AccurateMassSearchEngine::resolveAutoMode_(), TOPPASBase::saveCurrentPipelineAs(), TOPPASBase::savePipeline(), TOPPASBase::savePipelineAs(), and INIFileEditorWindow::updateWindowTitle().
|
static |
Return true if the file does not exist or the file is empty.
|
static |
Method used to test if a file
exists.
Referenced by TOPPViewBase::addDataFile(), MS2File::load(), MascotInfile::load(), MascotGenericFile::load(), TOPPASBase::loadPreferences(), and TOPPViewBase::loadPreferences().
|
static |
Retrieves a list of files matching file_pattern
in directory dir
(returns filenames without paths unless full_path
is true)
|
static |
Looks up the location of the file filename
.
The following locations are checked in this order:
directories
FileNotFound | is thrown, if the file is not found |
Referenced by QApplicationTOPP::QApplicationTOPP(), and DigestionEnzymeDB< DigestionEnzymeRNA, RNaseDB >::readEnzymesFromFile_().
uses File::find() to search for a file names db_name
in the 'id_db_dir' param of the OpenMS system parameters
FileNotFound | is thrown, if the file is not found |
Resolves a partial file name to a documentation file in the doc-folder.
Using find() to locate the documentation file under OPENMS_DATA_PATH, OPENMS_SOURCE_PATH, OPENMS_BINARY_PATH + "/../../doc" (or a variation for MacOS packages)
Will return the String with the full path to the local documentation. If this call fails, try the web documentation (http://www.openms.de/current_doxygen/) instead.
String | The doc file name to find. |
FileNotFound | is thrown, if the file is not found |
Searches for an executable with the given name.
toolName | The executable to search for. |
FileNotFound | is thrown, if the tool executable was not found. |
Referenced by TOPPViewBase::runTOPPTool_().
|
static |
Retrieve path of current executable (useful to find other TOPP tools) The returned path is either just an EMPTY string if the call to system subroutines failed or the complete path including a trailing "/", to enable usage of this function as File::getExecutablePath() + "mytool"
|
static |
Returns the OpenMS data path (environment variable overwrites the default installation path)
Referenced by TOPPASBase::openExampleDialog(), and TOPPViewBase::openExampleDialog().
|
static |
Returns the OpenMS home path (environment variable overwrites the default home path)
|
staticprivate |
get defaults for the system's Temp-path, user home directory etc.
|
static |
get the system's default OpenMS.ini file in the users home directory (<home>/OpenMS/OpenMS.ini) or create/repair it if required order: 1. <OPENMS_HOME_DIR>/OpenMS/OpenMS.ini if environmental variable set 2. user home directory <home>/OpenMS/OpenMS.ini
|
static |
The current OpenMS temporary data path (for temporary files)
Referenced by TOPPMetaProSIP::main_(), TOPPASBase::TOPPASBase(), and TOPPASBase::~TOPPASBase().
Obtain a temporary filename, ensuring automatic deletion upon exit.
The file is not actually created and only deleted at exit if it exists.
However, if 'alternative_file' is given and not empty, no temporary filename is created and 'alternative_file' is returned (and not destroyed upon exit). This is useful if you have an optional output file, which may, or may not be requested, but you need its content regardless, e.g. for intermediate plotting with R. Thus you can just call this function to get a file which can be used and gets automatically destroyed if needed.
alternative_file | If this string is not empty, no action is taken and it is used as return value |
|
static |
Returns a string, consisting of date, time, hostname, process id, and a incrementing number. This can be used for temporary files.
include_hostname | add hostname into result - potentially a long string |
Referenced by TOPPViewBase::showTOPPDialog_(), and TOPPASBase::TOPPASBase().
|
static |
The current OpenMS user data path (for result files) Tries to set the user directory in following order: 1. OPENMS_HOME_DIR if environmental variable set 2. "home_dir" entry in OpenMS.ini 3. user home directory
|
static |
Return true if the given path specifies a directory.
|
staticprivate |
Check if the given path is a valid OPENMS_DATA_PATH.
Returns the path of the file (without the file name).
Referenced by TOPPViewBase::updateCurrentPath(), and INIFileEditorWindow::updateWindowTitle().
|
static |
Return true if the file exists and is readable.
Referenced by TOPPViewBase::finishTOPPToolExecution(), MS2File::load(), and INIFileEditorWindow::openFile().
|
static |
Removes a file (if it exists).
Referenced by TOPPViewBase::finishTOPPToolExecution(), and TOPPViewBase::rerunTOPPTool().
|
static |
Removes the directory and all subdirectories (absolute path).
|
static |
Removes the subdirectories of the specified directory (absolute path). Returns true if successful.
Referenced by TOPPASBase::~TOPPASBase().
Returns the file name without the extension
The extension is the suffix of the string up to and including the last dot.
If no extension is found, the whole file name is returned
|
static |
Rename a file.
If from
and to
point to the same file (symlinks are resolved), no action will be taken and true is returned. If the target already exists (and is not identical to the source), this function will fail unless overwrite_existing
is true.
from | Source filename |
to | Target filename |
overwrite_existing | Delete already existing target, before renaming |
verbose | Print message to LOG_ERROR if something goes wrong. |
|
static |
Return true if the file is writable.
Referenced by TOPPViewBase::runTOPPTool_(), and TOPPViewBase::showTOPPDialog_().
|
friend |
|
staticprivate |
private list of temporary filenames, which are deleted upon program exit