Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Static Public Member Functions | Static Private Member Functions | Friends | List of all members
File Class Reference

Basic file handling operations. More...

#include <OpenMS/SYSTEM/File.h>

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 remove (const String &file)
 Removes a file (if it exists). More...
 
static bool removeDirRecursively (const String &dir_name)
 Removes the specified directory (absolute path). Returns true if successful. 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 ()
 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 getTempDirectory ()
 The current OpenMS temporary data path (for temporary files) More...
 
static String getUserDirectory ()
 The current OpenMS user data path (for result files) More...
 
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 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...
 

Friends

class TOPPBase
 

Detailed Description

Basic file handling operations.

Member Function Documentation

static String absolutePath ( const String file)
static

Replaces the relative path in the argument with the absolute path.

Referenced by TOPPViewBase::addDataFile(), and TOPPViewBase::addRecentFile_().

static String basename ( const String file)
static
static bool empty ( const String file)
static

Return true if the file does not exist or the file is empty.

static bool exists ( const String file)
static
static bool fileList ( const String dir,
const String file_pattern,
StringList output,
bool  full_path = false 
)
static

Retrieves a list of files matching file_pattern in directory dir (returns filenames without paths unless full_path is true)

Returns
true => there are matching files
static String find ( const String filename,
StringList  directories = StringList() 
)
static

Looks up the location of the file filename.

The following locations are checked in this order:

  • the directories in directories
  • the directory contained in the environment variable $OPENMS_DATA_PATH
  • the 'share/OpenMS/' directory of the OpenMS install directory
Exceptions
FileNotFoundis thrown, if the file is not found

Referenced by MzMLHandler< MSExperiment<> >::MzMLHandler().

static String findDatabase ( const String db_name)
static

uses File::find() to search for a file names db_name in the 'id_db_dir' param of the OpenMS system parameters

Exceptions
FileNotFoundis thrown, if the file is not found
static String findDoc ( const String filename)
static

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.

Parameters
StringThe doc file name to find.
Returns
The full path to the requested file.
Exceptions
FileNotFoundis thrown, if the file is not found

Referenced by TOPPASBase::showURL(), and TOPPViewBase::showURL().

static String findExecutable ( const String toolName)
static

Searches for an executable with the given name.

Parameters
toolNameThe executable to search for.
Exceptions
FileNotFoundis thrown, if the tool executable was not found.

Referenced by TOPPASBase::openFilesInTOPPView(), and TOPPViewBase::runTOPPTool_().

static String getExecutablePath ( )
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"

Referenced by TOPPASBase::openFilesInTOPPView().

static String getOpenMSDataPath ( )
static

Returns the OpenMS data path (environment variable overwrites the default installation path)

Referenced by TOPPASBase::openExampleDialog(), and TOPPViewBase::openExampleDialog().

static Param getSystemParameterDefaults_ ( )
staticprivate

get defaults for the system's Temp-path, user home directory etc.

static Param getSystemParameters ( )
static

get the system's default OpenMS.ini file in the users home directory (<home>/OpenMS/OpenMS.ini) or create/repair it if required

static String getTempDirectory ( )
static

The current OpenMS temporary data path (for temporary files)

Referenced by TOPPASBase::TOPPASBase(), and TOPPASBase::~TOPPASBase().

static String getUniqueName ( )
static

Returns a string, consisting of date, time, hostname, process id, and a incrementing number. This can be used for temporary files.

Referenced by TOPPViewBase::showTOPPDialog_(), and TOPPASBase::TOPPASBase().

static String getUserDirectory ( )
static

The current OpenMS user data path (for result files)

static bool isDirectory ( const String path)
static

Return true if the given path specifies a directory.

static bool isOpenMSDataPath_ ( const String path)
staticprivate

Check if the given path is a valid OPENMS_DATA_PATH.

static String path ( const String file)
static

Returns the path of the file (without the file name).

Referenced by FileHandler::loadExperiment(), TOPPViewBase::updateCurrentPath(), and INIFileEditorWindow::updateWindowTitle().

static bool readable ( const String file)
static

Return true if the file exists and is readable.

Referenced by TOPPViewBase::finishTOPPToolExecution(), MS2File::load(), and INIFileEditorWindow::openFile().

static bool remove ( const String file)
static

Removes a file (if it exists).

Returns
Returns true if the file was successfully deleted (or if it did not exist).

Referenced by TOPPViewBase::finishTOPPToolExecution(), and TOPPViewBase::rerunTOPPTool().

static bool removeDirRecursively ( const String dir_name)
static

Removes the specified directory (absolute path). Returns true if successful.

Referenced by TOPPASBase::~TOPPASBase().

static String removeExtension ( const String file)
static

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 bool writable ( const String file)
static

Return true if the file is writable.

Referenced by TOPPViewBase::runTOPPTool_(), and TOPPViewBase::showTOPPDialog_().

Friends And Related Function Documentation

friend class TOPPBase
friend

OpenMS / TOPP release 2.0.0 Documentation generated on Wed Mar 30 2016 16:18:48 using doxygen 1.8.5