Basic Image AlgorithmS Library
2.8.0
|
Functions to create, check and delete files and to handle file names, such as splitting into directory, filename and suffix. More...
#include <Base/Common/FileHandling.hh>
Static Public Member Functions | |
static std::string | Basename (const std::string &fullname) |
Get file base name without path from given path and filename. More... | |
static int | ChDir (const std::string &dir) |
Change current working directory. More... | |
static bool | CopyFileTo (const std::string &oldFilename, const std::string &newFilename) |
Copies the file with the given name. More... | |
static std::string | CorrectSlashes (const std::string &thepath) |
Replace wrong slashes with respect to current operating system. More... | |
static int | CreateDir (const std::string &subdir) |
Create directory (parent directory must exist). More... | |
static int | CreateDirRecursive (const std::string &dir) |
Create directory recursively (if any parent directory does not exist it will be created). More... | |
static std::string | CurrentDateTimeString () |
Create a string containing date and time like 20060329_173054. More... | |
static std::string | Directory (const std::string &fullname) |
Get directory from given path and filename. More... | |
static std::string | DirectoryAndBasename (const std::string &fullname) |
Get path and file base name (without suffix) from given path and filename. More... | |
static std::string | Extension (const std::string &fullname) |
Get file extension (without dot!) from given path and filename. More... | |
static int | ExtractNumberFromRight (const std::string &inStr, int &number, int &posL, int &posR) |
Extract numeric value from string beginning from right, e.g. More... | |
static bool | FileExists (const std::string &file) |
Check if the given file exists. More... | |
static std::string | Filename (const std::string &fullname) |
Get file name (base name + suffix) without path from given path and filename. More... | |
static int | FilenameExpansion (const std::string &in, std::string &out) |
Expand filename, e.g. More... | |
static int | FilenameSequence (const std::string &refFileName, std::string &resultFilename, const int &offsetFromRef, const unsigned int &stepsize=1) |
Construct sequential filename from a given filename by manipulating the number within base part of. More... | |
static bool | FileReadable (const std::string &filename) |
Checks if the given file exists and is readable on file system. More... | |
static std::string | GetApplicationPath () |
Return full path of current thread/application/module/exe/dll. More... | |
static std::string | GetCwd () |
Return current working directory as string. More... | |
static int | GetDirectoryContent (const std::string &Dir, const std::string &prefix, const std::string &suffix, std::vector< std::string > &content, const bool GetFullPath=false) |
Read all files in. More... | |
static bool | IsAbsolute (const std::string &path) |
Determines if path is absolute (starting with "/") or local. More... | |
static std::string | LeadingZeroString (const int &n, const unsigned int &digits=DEFAULT_LEADING_ZEROS) |
Create a string with leading zeroes from number. More... | |
static void | LogCommandLine (int argc, char **argv, std::ostream &os) |
Write compilation time/date and all command line arguments to an output stream. More... | |
static void | LogCommandLine (int argc, char **argv, const std::string &filename) |
Write compilation time/date and all command line arguments to a log file. More... | |
static std::string | LowerCase (const std::string &input) |
Return lower case string of input. More... | |
static bool | MoveOrRenameFile (const std::string &oldFilename, const std::string &newFilename) |
Renames or moves the file with the given name. More... | |
static int | RemoveDir (const std::string &subdir) |
Delete directory and all contents. More... | |
static bool | RemoveFile (const std::string &filename) |
Removes the file with the given name. More... | |
static void | SplitName (const std::string &fullname, std::string &dir, std::string &base, std::string &suffix) |
Split full path into: More... | |
static void | SplitPath (const std::string &fullpath, std::vector< std::string > &result) |
Split full directory name into individual subdirectory names, e.g. More... | |
static std::string | StripTerminatingSlash (const std::string &thepath) |
Remove a trailing slash from the path if there is one. More... | |
static std::string | Suffix (const std::string &fullname) |
Get file suffix (including dot!) from given path and filename. More... | |
template<class T > | |
static std::string | toString (const T thenumber, int numzeros=DEFAULT_LEADING_ZEROS) |
Converts number to string with leading zeros. More... | |
static std::string | UpperCase (const std::string &input) |
Return upper case string of input. More... | |
Functions to create, check and delete files and to handle file names, such as splitting into directory, filename and suffix.
Definition at line 47 of file FileHandling.hh.
|
static |
Get file base name without path from given path and filename.
Definition at line 314 of file FileHandling.cpp.
Referenced by BIAS::SceneOpenSceneGraph::AppendSubTreeFromFile(), BIAS::SceneOpenSceneGraph::AppendSubTreeFromImageFile(), BIAS::BVWXMainFrame::OnSaveAs(), BIAS::BVWXMainFrame::OnSaveAsMovie(), BIAS::BVWXMainFrame::OnSaveCurrent(), and BIAS::VideoSource_DiskPMD::OpenDevice().
|
static |
Change current working directory.
Definition at line 629 of file FileHandling.cpp.
|
static |
Copies the file with the given name.
Definition at line 226 of file FileHandling.cpp.
|
inlinestatic |
Replace wrong slashes with respect to current operating system.
Definition at line 233 of file FileHandling.hh.
|
static |
Create directory (parent directory must exist).
Definition at line 86 of file FileHandling.cpp.
|
static |
Create directory recursively (if any parent directory does not exist it will be created).
Definition at line 104 of file FileHandling.cpp.
|
static |
Create a string containing date and time like 20060329_173054.
Definition at line 449 of file FileHandling.cpp.
Referenced by BIAS::LDA::ComputeReductionMatrix().
|
static |
Get directory from given path and filename.
Definition at line 307 of file FileHandling.cpp.
Referenced by BIAS::BVWXMainFrame::OnSaveAs(), BIAS::BVWXMainFrame::OnSaveAsMovie(), and BIAS::BVWXMainFrame::OnSaveCurrent().
|
static |
Get path and file base name (without suffix) from given path and filename.
Definition at line 351 of file FileHandling.cpp.
Referenced by BIAS::ImageIO::ExtensionName().
|
static |
Get file extension (without dot!) from given path and filename.
Definition at line 328 of file FileHandling.cpp.
Referenced by BIAS::ImageIO::ExportMatrix(), BIAS::ImageIO::ExtensionName(), BIAS::ImageIO::GetFileFormat(), BIAS::ImageIO::ImportMatrix(), BIAS::ImageAttributes::ReadMagickPP(), and BIAS::ThreeDOutOpenSceneGraph::WriteToFile().
|
static |
Extract numeric value from string beginning from right, e.g.
"blah042foo.txt" –> return 42 and positions of "0" and "2".
Definition at line 469 of file FileHandling.cpp.
|
static |
Check if the given file exists.
Definition at line 138 of file FileHandling.cpp.
Referenced by BIAS::clfProgram::AddSource().
|
static |
Get file name (base name + suffix) without path from given path and filename.
Definition at line 344 of file FileHandling.cpp.
|
static |
Expand filename, e.g.
tilde to home expands "~" to $HOME if set and $USERPROFILE otherwise.
Definition at line 561 of file FileHandling.cpp.
Referenced by BIAS::ImageIO::Load(), BIAS::XMLIO::read(), BIAS::ImageIO::Save(), and BIAS::XMLIO::write().
|
static |
Construct sequential filename from a given filename by manipulating the number within base part of.
refFilename | of an image sequence given a reference filename and an offset. The number of leading zeroes is kept but digits may be added if required. |
offsetFromRef | Number of frames forward or backward from ref. image |
stepsize | Number of increment/decrement per offset |
Example: C:/foo/image00100bar.jpg ref=100, offset=2, stepsize=7 –> 114 resultFilename –> C:/foo/image00114bar.jpg or: foo9 -> foo10 foo009 -> foo010
Definition at line 528 of file FileHandling.cpp.
|
static |
Checks if the given file exists and is readable on file system.
Definition at line 217 of file FileHandling.cpp.
|
static |
Return full path of current thread/application/module/exe/dll.
Definition at line 638 of file FileHandling.cpp.
|
static |
Return current working directory as string.
Definition at line 599 of file FileHandling.cpp.
Referenced by BIAS::ImageIO::Load(), BIAS::Projection::Load(), and BIAS::ProjectionParametersIO::ReadRigData().
|
static |
Read all files in.
Dir,match | against |
suffix | and |
prefix | and put into |
content. | If you want to use the full path, set |
GetFullPath=true,otherwise | only the file name is used. |
Definition at line 147 of file FileHandling.cpp.
Referenced by BIAS::VideoSource_V4L::GetAllDevices().
|
static |
Determines if path is absolute (starting with "/") or local.
Definition at line 654 of file FileHandling.cpp.
|
static |
Create a string with leading zeroes from number.
Definition at line 419 of file FileHandling.cpp.
Referenced by BIAS::MixtureOfGaussians< StorageType >::Apply(), BIAS::clfUnifiedMultilateralFilter::Compute(), BIAS::ShowCamWxFrame::CreateImageSaveThreadForCamera_(), BIAS::CylindricDepthTrackingPanorama::GetTriangleMesh(), BIAS::ShowCamWxFrame::OnGrab(), BIAS::ExampleMixtureOfGaussiansFrame::OnTimer(), BIAS::CylindricDepthPanorama::ProcessCylindricProjection(), BIAS::OpenGLCanvasBase::ScreenShot(), and BIAS::ShowCamWxFrame::StartSavingImagesToDisk().
|
static |
Write compilation time/date and all command line arguments to an output stream.
Definition at line 392 of file FileHandling.cpp.
|
static |
Write compilation time/date and all command line arguments to a log file.
Definition at line 405 of file FileHandling.cpp.
|
static |
Return lower case string of input.
Definition at line 433 of file FileHandling.cpp.
Referenced by BIAS::ImageIO::ExportMagickPP(), BIAS::ImageIO::ExtensionName(), BIAS::XMLIO::getAttributeValueBool(), BIAS::ImageIO::GetFileFormat(), and BIAS::ParamTypeBool::SetFromString().
|
inlinestatic |
Renames or moves the file with the given name.
Just wraps C call.
Definition at line 87 of file FileHandling.hh.
|
static |
Delete directory and all contents.
Definition at line 69 of file FileHandling.cpp.
|
inlinestatic |
Removes the file with the given name.
Just wraps C call.
Definition at line 80 of file FileHandling.hh.
|
static |
Split full path into:
- directory - file base name - file suffix (including dot!)
Definition at line 243 of file FileHandling.cpp.
Referenced by BIAS::ScenePlainOpenSceneGraph::AppendSubTreeFromFile(), BIAS::SceneOpenSceneGraph::AppendSubTreeFromFile(), BIAS::ThreeDOutOpenSceneGraph::GenerateFilename_(), BIAS::SceneOpenSceneGraph::Load(), BIAS::ThreeDOutOpenSceneGraph::OpenSceneGraphOut(), BIAS::SceneOpenSceneGraph::Save(), and BIAS::SceneOpenSceneGraph::SaveSubTree().
|
static |
Split full directory name into individual subdirectory names, e.g.
/home/user/data -> ["home", "user", "data"].
fullpath,it | will be returned as the last element of |
result! |
Definition at line 369 of file FileHandling.cpp.
|
inlinestatic |
Remove a trailing slash from the path if there is one.
Definition at line 215 of file FileHandling.hh.
|
static |
Get file suffix (including dot!) from given path and filename.
Definition at line 321 of file FileHandling.cpp.
Referenced by BIAS::SceneOpenSceneGraph::AppendSubTreeFromFile(), BIAS::SceneOpenSceneGraph::AppendSubTreeFromImageFile(), BIAS::ImageIO::ExportMagickPP(), and BIAS::VideoSource_DiskPMD::OpenDevice().
|
inlinestatic |
Converts number to string with leading zeros.
Definition at line 98 of file FileHandling.hh.
Referenced by BIAS::ImageAlignment::Align(), BIAS::TrackerBaseAffine< StorageType >::TrackAffine_(), and BIAS::TrackerBaseAffine2< StorageType >::TrackAffine_().
|
static |
Return upper case string of input.
Definition at line 441 of file FileHandling.cpp.