Functions
urdf_traverser::helpers Namespace Reference

Functions

void deleteFile (const char *file)
bool directoryExists (const char *dPath)
void enforceDirectory (std::string &path, bool printWarn)
bool fileExists (const char *file)
std::string fileExtension (const char *file)
void findAndReplace (const std::string &newStr, const std::string &oldStr, const std::string &in, std::string &out)
bool getCommonParentPath (const std::string &p1, const std::string &p2, std::string &result)
bool getCommonParentPath (const std::set< std::string > &allFiles, std::string &result)
std::string getDirectory (const std::string &path)
std::string getDirectoryName (const std::string &path)
std::string getFilename (const char *file)
std::string getFilenameWithoutExtension (const char *file)
std::string getPath (const char *file)
bool getRelativeDirectory (const std::string &path, const std::string &relTo, std::string &result)
bool getSubdirPath (const std::string &from, const std::string &to, std::string &result)
bool isDirectoryPath (const std::string &path)
bool makeDirectoryIfNeeded (const char *dPath)
std::string packagePathToAbsolute (std::string &packagePath)
std::string replaceAll (const std::string &text, const std::string &from, const std::string &to)
bool writeToFile (const std::string &content, const std::string &filename)

Function Documentation

void urdf_traverser::helpers::deleteFile ( const char *  file)

Definition at line 63 of file Helpers.cpp.

bool urdf_traverser::helpers::directoryExists ( const char *  dPath)

Definition at line 94 of file Helpers.cpp.

void urdf_traverser::helpers::enforceDirectory ( std::string &  path,
bool  printWarn 
)

Ensures this path is in the form such that it refers to a directory. For example (on unix): (1) this/is/a/file while (2) this/is/a/directory/. This method enforces the form (2) for path.

Parameters:
printWarnprint a warning if the directory needs to be altered

Definition at line 199 of file Helpers.cpp.

bool urdf_traverser::helpers::fileExists ( const char *  file)

Definition at line 68 of file Helpers.cpp.

std::string urdf_traverser::helpers::fileExtension ( const char *  file)

################################################################################################################ Minor helpers (e.g. file writing)

Author:
Jennifer Buehler
Date:
last edited October 2015 ################################################################################################################

Definition at line 86 of file Helpers.cpp.

void urdf_traverser::helpers::findAndReplace ( const std::string &  newStr,
const std::string &  oldStr,
const std::string &  in,
std::string &  out 
)

################################################################################################################ Minor helpers (e.g. file writing)

Author:
Jennifer Buehler
Date:
last edited October 2015 ################################################################################################################

Definition at line 52 of file Helpers.cpp.

bool urdf_traverser::helpers::getCommonParentPath ( const std::string &  p1,
const std::string &  p2,
std::string &  result 
)

Determines the common parent path of p1 and p2. If paths are relative, they are converted to absolute relative to the current directory Returns false if there is no commom path, which means the paths don't have a common root. An empty path is returned only if both paths are relative, and the common parent is the directory they are both relative to.

Definition at line 270 of file Helpers.cpp.

bool urdf_traverser::helpers::getCommonParentPath ( const std::set< std::string > &  allFiles,
std::string &  result 
)

Returns the common parent path of all paths in the set by calling other getCommonParentPath().

Definition at line 346 of file Helpers.cpp.

std::string urdf_traverser::helpers::getDirectory ( const std::string &  path)

Returns boost::filesystem::path(path).parent_path() if the path is a file, and if path is a directory, returns the path itself

Definition at line 247 of file Helpers.cpp.

std::string urdf_traverser::helpers::getDirectoryName ( const std::string &  path)

Returns the name of the directory at the lowest level (eg. name of the directory a file is in, not the whole path - only the directory name).

Definition at line 258 of file Helpers.cpp.

std::string urdf_traverser::helpers::getFilename ( const char *  file)

Definition at line 73 of file Helpers.cpp.

std::string urdf_traverser::helpers::getFilenameWithoutExtension ( const char *  file)

Definition at line 79 of file Helpers.cpp.

std::string urdf_traverser::helpers::getPath ( const char *  file)

Definition at line 100 of file Helpers.cpp.

bool urdf_traverser::helpers::getRelativeDirectory ( const std::string &  path,
const std::string &  relTo,
std::string &  result 
)

Returns file or directory path relative to directory relTo. Example: path is my/special/file.txt, and relTo is target/directory/. Then the result would be ../../my/special/file.txt Both paths either (1) should exist, or (2) be symbolic (not exist), in which case the endings will determine whether they are a directory or not (for example on unix: this/is/a/file while this/is/a/directory/. To enforce a directory, you may use enforceDirectory()).

If either path or relTo are relative paths, they will temporarily be converted to absolute paths within the current directory.

Returns:
false if path and relTo have no common parent path (there has to be at least a common root).

Definition at line 373 of file Helpers.cpp.

bool urdf_traverser::helpers::getSubdirPath ( const std::string &  from,
const std::string &  to,
std::string &  result 
)

When to is a subdirectory of from, the relative path from from to to is returned. If to is not a subdirectory of from, false is returned and the result is undefined. If both from and to are directories, and they are the same, "." is returned for current directory) If from is a file and not a directory, an exception is thrown.

Definition at line 142 of file Helpers.cpp.

bool urdf_traverser::helpers::isDirectoryPath ( const std::string &  path)

Checks if the path references a directory, ie. it must end with a separator. Does not actually check if the directory or file exists, so this can be used to check paths which are to be created.

Definition at line 135 of file Helpers.cpp.

bool urdf_traverser::helpers::makeDirectoryIfNeeded ( const char *  dPath)

Definition at line 106 of file Helpers.cpp.

std::string urdf_traverser::helpers::packagePathToAbsolute ( std::string &  packagePath)

Definition at line 447 of file Helpers.cpp.

std::string urdf_traverser::helpers::replaceAll ( const std::string &  text,
const std::string &  from,
const std::string &  to 
)

Replace all occurrences of from in the string text and replace them with to

Definition at line 212 of file Helpers.cpp.

bool urdf_traverser::helpers::writeToFile ( const std::string &  content,
const std::string &  filename 
)

Definition at line 426 of file Helpers.cpp.



urdf_traverser
Author(s): Jennifer Buehler
autogenerated on Fri Mar 1 2019 03:38:07