ViSP
2.10.0
|
#include <vpIoTools.h>
Static Public Member Functions | |
static void | getUserName (std::string &username) |
static std::string | getUserName () |
static std::string | getenv (const char *env) |
static std::string | getenv (const std::string &env) |
static std::string | getViSPImagesDataPath () |
static void | getVersion (const std::string &version, unsigned int &major, unsigned int &minor, unsigned int &patch) |
static bool | checkDirectory (const char *dirname) |
static bool | checkDirectory (const std::string &dirname) |
static bool | checkFilename (const char *filename) |
static bool | checkFilename (const std::string &filename) |
static bool | copy (const char *src, const char *dst) |
static bool | copy (const std::string &src, const std::string &dst) |
static void | makeDirectory (const char *dirname) |
static void | makeDirectory (const std::string &dirname) |
static bool | remove (const char *filename) |
static bool | remove (const std::string &filename) |
static bool | rename (const char *oldfilename, const char *newfilename) |
static bool | rename (const std::string &oldfilename, const std::string &newfilename) |
static std::string | path (const char *pathname) |
static std::string | path (const std::string &pathname) |
static std::string | getFileExtension (const std::string &pathname, const bool checkFile=false) |
static std::string | getName (const std::string &pathname) |
static std::string | getNameWE (const std::string &pathname) |
static std::string | getParent (const std::string &pathname) |
static std::string | createFilePath (const std::string &parent, const std::string child) |
static bool | isAbsolutePathname (const std::string &pathname) |
static std::pair< std::string, std::string > | splitDrive (const std::string &pathname) |
static bool | loadConfigFile (const std::string &confFile) |
static bool | readConfigVar (const std::string &var, float &value) |
static bool | readConfigVar (const std::string &var, double &value) |
static bool | readConfigVar (const std::string &var, int &value) |
static bool | readConfigVar (const std::string &var, unsigned int &value) |
static bool | readConfigVar (const std::string &var, bool &value) |
static bool | readConfigVar (const std::string &var, std::string &value) |
static bool | readConfigVar (const std::string &var, vpColor &value) |
static bool | readConfigVar (const std::string &var, vpMatrix &value, const unsigned int &nCols=0, const unsigned int &nRows=0) |
static void | setBaseName (const std::string &s) |
static void | setBaseDir (const std::string &dir) |
static void | addNameElement (const std::string &strTrue, const bool &cond=true, const std::string &strFalse="") |
static void | addNameElement (const std::string &strTrue, const double &val) |
static std::string | getBaseName () |
static std::string | getFullName () |
static void | saveConfigFile (const bool &actuallySave=true) |
static void | createBaseNamePath (const bool &empty=false) |
Static Public Attributes | |
static const char | separator |
Static Protected Attributes | |
static std::string | baseName = "" |
static std::string | baseDir = "" |
static std::string | configFile = "" |
static std::vector< std::string > | configVars = std::vector<std::string>() |
static std::vector< std::string > | configValues = std::vector<std::string>() |
File and directories basic tools.
The example below shows how to manipulate the functions of this class to create first a directory which name corresponds to the user name and then create a file in this directory.
The example below shows how to read a configuration file and how to create a name for experiment files. We assume the following file "/home/user/demo/config.txt" :
Definition at line 155 of file vpIoTools.h.
|
static |
Augments the prefix of the experiment files by strTrue if cond is verified, and by strFalse otherwise.
strTrue | : String to add if cond is true |
cond | : Condition managing the file name |
strFalse | : String to add if cond is false (default "") |
Definition at line 996 of file vpIoTools.cpp.
References baseName.
|
static |
Augments the prefix of the experiment files by strTrue followed by val.
strTrue | : String to add |
val | : Value to add |
Definition at line 1011 of file vpIoTools.cpp.
References baseName.
|
static |
Check if a directory exists.
dirname | : Directory to test if it exists. The directory name is converted to the current system's format; see path(). |
Definition at line 315 of file vpIoTools.cpp.
References path().
Referenced by checkDirectory(), copy(), createBaseNamePath(), getFileExtension(), vpSimulatorAfma6::init(), vpSimulatorViper850::init(), vpSimulatorAfma6::initArms(), vpSimulatorViper850::initArms(), makeDirectory(), vpServoData::open(), remove(), and vpWireFrameSimulator::vpWireFrameSimulator().
|
static |
Check if a directory exists.
dirname | : Directory to test if it exists. The directory name is converted to the current system's format; see path(). |
Definition at line 365 of file vpIoTools.cpp.
References checkDirectory().
|
static |
Check if a file exists.
filename | : Filename to test if it exists. |
Definition at line 465 of file vpIoTools.cpp.
References path().
Referenced by checkFilename(), copy(), vpDot2::defineDots(), getFileExtension(), getViSPImagesDataPath(), vpAROgre::init(), vpMbTracker::initClick(), vpMbTracker::loadCAOModel(), vpMbTracker::loadModel(), vpImageIo::read(), and remove().
|
static |
Check if a file exists.
filename | : Filename to test if it exists. |
Definition at line 513 of file vpIoTools.cpp.
References checkFilename().
|
static |
Copy a src file or directory in dst.
src | : Existing file or directory to copy. |
dst | : New copied file or directory. |
Definition at line 531 of file vpIoTools.cpp.
References checkDirectory(), checkFilename(), and path().
Referenced by copy(), and saveConfigFile().
|
static |
Copy a src file or directory in dst.
src | : Existing file or directory to copy. |
dst | : New copied file or directory. |
Definition at line 581 of file vpIoTools.cpp.
References copy().
|
static |
Creates the directory baseDir/baseName. If already exists, empties it if empty is true. Useful to save the images corresponding to a particular experiment.
empty | : Indicates if the new directory has to be emptied |
Definition at line 1031 of file vpIoTools.cpp.
References baseDir, baseName, checkDirectory(), makeDirectory(), and remove().
|
static |
Return the file path that corresponds to the concatenated parent and child string files by adding the corresponding separator for unix or windows.
The corresponding path is also converted. Under windows, all the "/" characters are converted into "\\" characters. Under Unix systems all the "\\" characters are converted into "/" characters.
Definition at line 1245 of file vpIoTools.cpp.
References path(), and separator.
Referenced by vpMbTracker::loadCAOModel().
|
inlinestatic |
Gets the base name (prefix) of the experiment files.
Definition at line 234 of file vpIoTools.h.
|
static |
Get the content of an environment variable.
env | : Environment variable name (HOME, LOGNAME...). |
vpIoException::cantGetenv | : If an error occur while getting the environment variable value. |
Definition at line 204 of file vpIoTools.cpp.
References vpIoException::cantGetenv, and vpERROR_TRACE.
Referenced by getenv(), getUserName(), getViSPImagesDataPath(), vpSimulatorAfma6::init(), vpSimulatorViper850::init(), vpSimulatorAfma6::initArms(), vpSimulatorViper850::initArms(), and vpWireFrameSimulator::vpWireFrameSimulator().
|
static |
Get the content of an environment variable.
env | : Environment variable name (HOME, LOGNAME...). |
vpIoException::cantGetenv | : If an error occur while getting the environment variable value. |
Definition at line 253 of file vpIoTools.cpp.
References getenv().
|
static |
Returns the extension of the file or an empty string if the file has no extension. If checkFile flag is set, it will check first if the pathname denotes a directory and so return an empty string and second it will check if the file denoted by the pathanme exists. If so, it will return the extension if present.
pathname | : The pathname of the file we want to get the extension. |
checkFile | : If true, the file must exist otherwise an empty string will be returned. |
Definition at line 1105 of file vpIoTools.cpp.
References checkDirectory(), and checkFilename().
|
inlinestatic |
Gets the full path of the experiment files : baseDir/baseName
Definition at line 240 of file vpIoTools.h.
|
static |
Returns the name of the file or directory denoted by this pathname.
Definition at line 1185 of file vpIoTools.cpp.
References path(), and separator.
Referenced by getNameWE(), and vpMbTracker::loadCAOModel().
|
static |
Returns the name of the file without extension or directory denoted by this pathname.
Definition at line 1207 of file vpIoTools.cpp.
References getName().
|
static |
Returns the pathname string of this pathname's parent.
Definition at line 1220 of file vpIoTools.cpp.
References path(), and separator.
Referenced by vpMbTracker::loadCAOModel(), vpKeyPoint::loadLearningData(), and vpKeyPoint::saveLearningData().
|
static |
Get the user name.
username | : The user name. |
vpIoException::cantGetUserName | : If this method cannot get the user name. |
Definition at line 94 of file vpIoTools.cpp.
References vpIoException::cantGetUserName, getenv(), and vpERROR_TRACE.
|
static |
Get the user name.
vpIoException::cantGetUserName | : If this method cannot get the user name. |
Definition at line 141 of file vpIoTools.cpp.
References vpIoException::cantGetUserName, getenv(), and vpERROR_TRACE.
|
static |
Extract major, minor and patch from a version given as "x.x.x". Ex: If version is "1.2.1", major will be 1, minor 2 and patch 1.
version | : String to extract the values. |
major | : Extracted major. |
minor | : Extracted minor. |
patch | : Extracted patch. |
Definition at line 268 of file vpIoTools.cpp.
|
static |
Get ViSP images data path. ViSP images data can be installed from Debian or Ubuntu visp-images-data package. It can be also installed from ViSP-images.zip that can be found on http://team.inria.fr/lagadic/visp/download.html page.
This function returns the path to the folder that contains the data.
If the path is not found, returns an empty string.
Definition at line 1071 of file vpIoTools.cpp.
References checkFilename(), and getenv().
|
static |
Return whether a path is absolute.
Definition at line 1291 of file vpIoTools.cpp.
References path(), and splitDrive().
Referenced by vpMbTracker::loadCAOModel(), and vpKeyPoint::loadLearningData().
|
static |
Reads the configuration file and parses it.
confFile | : path to the file containing the configuration parameters to parse. |
Definition at line 740 of file vpIoTools.cpp.
References configFile, configValues, configVars, vpMath::minimum(), and path().
|
static |
Create a new directory.
dirname | : Directory to create. The directory name is converted to the current system's format; see path(). |
vpIoException::invalidDirectoryName | : The dirname is invalid. |
vpIoException::cantCreateDirectory | : If the directory cannot be created. |
Definition at line 384 of file vpIoTools.cpp.
References vpIoException::cantCreateDirectory, checkDirectory(), vpIoException::invalidDirectoryName, path(), vpDEBUG_TRACE, and vpERROR_TRACE.
Referenced by createBaseNamePath(), makeDirectory(), vpServoData::open(), and vpKeyPoint::saveLearningData().
|
static |
Create a new directory.
dirname | : Directory to create. The directory name is converted to the current system's format; see path(). |
vpIoException::cantCreateDirectory | : If the directory cannot be created. |
Definition at line 439 of file vpIoTools.cpp.
References vpIoException::cantCreateDirectory, makeDirectory(), and vpERROR_TRACE.
|
static |
Converts a path name to the current system's format.
pathname | : Path name to convert. Path name to convert. Under windows, converts all the "/" characters in the pathname string into "\\" characters. Under Unix systems converts all the "\\" characters in the pathname string into "/" characters. |
Definition at line 695 of file vpIoTools.cpp.
Referenced by checkDirectory(), checkFilename(), copy(), createFilePath(), getName(), getParent(), isAbsolutePathname(), loadConfigFile(), makeDirectory(), path(), and remove().
|
static |
Converts a path name to the current system's format.
pathname | : Path name to convert. Under windows, converts all the "/" characters in the pathname string into "\\" characters. Under Unix systems converts all the "\\" characters in the pathname string into "/" characters. |
Definition at line 727 of file vpIoTools.cpp.
References path().
|
static |
Tries to read the parameter named var as a float.
var | : Name of the parameter in the configuration file. |
value | : Value to be read. |
Definition at line 791 of file vpIoTools.cpp.
References configValues, and configVars.
Referenced by readConfigVar().
|
static |
Tries to read the parameter named var as a double.
var | : Name of the parameter in the configuration file. |
value | : Value to be read. |
Definition at line 821 of file vpIoTools.cpp.
References configValues, and configVars.
|
static |
Tries to read the parameter named var as a int.
var | : Name of the parameter in the configuration file. |
value | : Value to be read. |
Definition at line 852 of file vpIoTools.cpp.
References configValues, and configVars.
|
static |
Tries to read the parameter named var as a unsigned int.
var | : Name of the parameter in the configuration file. |
value | : Value to be read. |
Definition at line 876 of file vpIoTools.cpp.
References readConfigVar().
|
static |
Tries to read the parameter named var as a bool.
var | : Name of the parameter in the configuration file. |
value | : Value to be read. |
Definition at line 892 of file vpIoTools.cpp.
References readConfigVar().
|
static |
Tries to read the parameter named var as a std::string.
var | : Name of the parameter in the configuration file. |
value | : Value to be read. |
Definition at line 924 of file vpIoTools.cpp.
References configValues, and configVars.
|
static |
Tries to read the parameter named var as a vpColor.
var | : Name of the parameter in the configuration file. |
value | : Value to be read. See vpColor.cpp for the color number. |
Definition at line 908 of file vpIoTools.cpp.
References vpColor::getColor(), and readConfigVar().
|
static |
Tries to read the parameter named var as a vpMatrix. If nCols and nRows are indicated, will resize the matrix. Otherwise, will try to read as many values as indicated by the dimension of value.
var | : Name of the parameter in the configuration file. |
value | : Value to be read. |
nCols | : Column dimension if resized. |
nRows | : Row dimension if resized |
Definition at line 952 of file vpIoTools.cpp.
References configValues, configVars, vpMatrix::getCols(), vpMatrix::getRows(), and vpMatrix::resize().
|
static |
Remove a file or a directory.
file_or_dir | : File or directory to remove. |
Definition at line 597 of file vpIoTools.cpp.
References checkDirectory(), checkFilename(), and path().
Referenced by createBaseNamePath(), and remove().
|
static |
Remove a file or a directory.
file_or_dir | : File or directory to remove. |
Definition at line 638 of file vpIoTools.cpp.
References remove().
|
static |
Rename an existing file oldfilename in newfilename.
oldfilename | : File to rename. |
newfilename | : New file name. |
Definition at line 655 of file vpIoTools.cpp.
Referenced by rename().
|
static |
Rename an existing file oldfilename in newfilename.
oldfilename | : File to rename. |
newfilename | : New file name. |
Definition at line 675 of file vpIoTools.cpp.
References rename().
|
static |
Copy the initial configuration file to the experiment directory.
actuallySave | : If false, do not copy the file. |
Definition at line 1051 of file vpIoTools.cpp.
References baseDir, baseName, configFile, and copy().
|
inlinestatic |
Sets the base directory of the experiment files.
dir | : Directory where the data will be saved. |
Definition at line 224 of file vpIoTools.h.
|
inlinestatic |
Sets the base name (prefix) of the experiment files.
s | : Prefix of the experiment files. |
Definition at line 218 of file vpIoTools.h.
|
static |
Split a path in a drive specification (a drive letter followed by a colon) and the path specification. It is always true that drivespec + pathspec == p Inspired by the Python 2.7.8 module.
Definition at line 1315 of file vpIoTools.cpp.
Referenced by isAbsolutePathname().
|
staticprotected |
Definition at line 248 of file vpIoTools.h.
Referenced by createBaseNamePath(), and saveConfigFile().
|
staticprotected |
Definition at line 247 of file vpIoTools.h.
Referenced by addNameElement(), createBaseNamePath(), and saveConfigFile().
|
staticprotected |
Definition at line 249 of file vpIoTools.h.
Referenced by loadConfigFile(), and saveConfigFile().
|
staticprotected |
Definition at line 251 of file vpIoTools.h.
Referenced by loadConfigFile(), and readConfigVar().
|
staticprotected |
Definition at line 250 of file vpIoTools.h.
Referenced by loadConfigFile(), and readConfigVar().
|
static |
Define the directory separator character, backslash ('\') for windows platform or slash ('/') otherwise.
Definition at line 184 of file vpIoTools.h.
Referenced by createFilePath(), getName(), and getParent().