Gazebo Common

API Reference

4.7.0
gz/common/Filesystem.hh File Reference
#include <memory>
#include <string>
#include <gz/common/config.hh>
#include <gz/common/Export.hh>
#include <gz/common/SuppressWarning.hh>

Go to the source code of this file.

Classes

class  DirIter
 A class for iterating over all items in a directory. More...
 

Namespaces

 ignition
 Forward declarations for the common classes.
 
 ignition::common
 

Enumerations

enum  FilesystemWarningOp { FSWO_LOG_WARNINGS = 0, FSWO_SUPPRESS_WARNINGS }
 Options for how to handle errors that occur in functions that manipulate the filesystem. More...
 

Functions

std::string absPath (const std::string &_path)
 Get the absolute path of a provided path. Relative paths are resolved relative to the current working directory. More...
 
std::string basename (const std::string &_path)
 Given a path, get just the basename portion. More...
 
void changeFromUnixPath (std::string &_path)
 Replace forward-slashes '/' with the preferred directory separator of the current operating system. On Windows, this will turn forward-slashes into backslashes. If forward-slash is the preferred separator of the current operating system, this will do nothing. More...
 
void changeToUnixPath (std::string &_path)
 Replace the preferred directory separator of the current operating system with a forward-slash '/'. On Windows, this will turn backslashes into forward-slashes. More...
 
bool chdir (const std::string &_dir)
 Change current working directory to _dir. More...
 
bool copyDirectory (const std::string &_existingDirname, const std::string &_newDirname, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Copy a directory, overwrite the destination directory if exists. More...
 
bool copyFile (const std::string &_existingFilename, const std::string &_newFilename, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Copy a file. More...
 
std::string copyFromUnixPath (const std::string &_path)
 Returns a copy of _path which has been passed through changeFromUnixPath. More...
 
std::string copyToUnixPath (const std::string &_path)
 Returns a copy of _path which has been passed through changeToUnixPath. More...
 
bool createDirectories (const std::string &_path)
 Create directories for the given path errors are printed on ignerr. More...
 
bool createDirectories (const std::string &_path, std::ostream &_errorOut)
 Create directories for the given path errors are printed to the given stream. More...
 
bool createDirectory (const std::string &_path)
 Create a new directory on the filesystem. Intermediate directories must already exist. More...
 
std::string cwd ()
 Get the current working directory. More...
 
bool exists (const std::string &_path)
 Determine whether the given path exists on the filesystem. More...
 
bool isDirectory (const std::string &_path)
 Determine whether the given path is a directory. More...
 
bool isFile (const std::string &_path)
 Check if the given path is a file. More...
 
std::string joinPaths (const std::string &_path)
 base case for joinPaths(...) below More...
 
std::string joinPaths (const std::string &_path1, const std::string &_path2)
 Join two strings together to form a path. More...
 
template<typename... Args>
std::string joinPaths (const std::string &_path1, const std::string &_path2, Args const &..._args)
 Append one or more additional path elements to the first passed in argument. More...
 
bool moveFile (const std::string &_existingFilename, const std::string &_newFilename, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Move a file. More...
 
std::string parentPath (const std::string &_path)
 Given a path, get just its parent path portion, without separator at the end. More...
 
bool removeAll (const std::string &_path, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove a file or a directory and all its contents. More...
 
bool removeDirectory (const std::string &_path, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove an empty directory. More...
 
bool removeDirectoryOrFile (const std::string &_path, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove an empty directory or file. More...
 
bool removeFile (const std::string &_existingFilename, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove a file. More...
 
const std::string separator (std::string const &_s)
 Append the preferred path separator character for this platform onto the passed-in string. More...
 
std::string uniqueDirectoryPath (const std::string &_dir)
 Unique directory path to not overwrite existing directory. More...
 
std::string uniqueFilePath (const std::string &_pathAndName, const std::string &_extension)
 Generates a path for a file which doesn't collide with existing files, by appending numbers to it (i.e. (0), (1), ...) More...