Gazebo Common

API Reference

6.0.1
Filesystem.hh File Reference
#include <string>
#include <gz/common/Export.hh>
#include <gz/utils/ImplPtr.hh>

Go to the source code of this file.

Classes

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

Namespaces

namespace  gz
 Forward declarations for the common classes.
 
namespace  gz::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.
 
std::string basename (const std::string &_path)
 Given a path, get just the basename portion.
 
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.
 
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.
 
bool chdir (const std::string &_dir)
 Change current working directory to _dir.
 
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.
 
bool copyFile (const std::string &_existingFilename, const std::string &_newFilename, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Copy a file.
 
std::string copyFromUnixPath (const std::string &_path)
 Returns a copy of _path which has been passed through changeFromUnixPath.
 
std::string copyToUnixPath (const std::string &_path)
 Returns a copy of _path which has been passed through changeToUnixPath.
 
bool createDirectories (const std::string &_path)
 Create directories for the given path.
 
bool createDirectory (const std::string &_path)
 Create a new directory on the filesystem. Intermediate directories must already exist.
 
std::string cwd ()
 Get the current working directory.
 
bool exists (const std::string &_path)
 Determine whether the given path exists on the filesystem.
 
bool isDirectory (const std::string &_path)
 Determine whether the given path is a directory.
 
bool isFile (const std::string &_path)
 Check if the given path is a file.
 
bool isRelativePath (const std::string &_path)
 Check if the given path is relative.
 
std::string joinPaths (const std::string &_path)
 base case for joinPaths(...) below
 
std::string joinPaths (const std::string &_path1, const std::string &_path2)
 Join two strings together to form a path.
 
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.
 
bool moveFile (const std::string &_existingFilename, const std::string &_newFilename, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Move a file.
 
std::string parentPath (const std::string &_path)
 Given a path, get just its parent path portion, without separator at the end.
 
bool removeAll (const std::string &_path, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove a file or a directory and all its contents.
 
bool removeDirectory (const std::string &_path, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove an empty directory.
 
bool removeDirectoryOrFile (const std::string &_path, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove an empty directory or file.
 
bool removeFile (const std::string &_existingFilename, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove a file.
 
std::string const separator (std::string const &_s)
 Append the preferred path separator character for this platform onto the passed-in string.
 
std::string uniqueDirectoryPath (const std::string &_dir)
 Unique directory path to not overwrite existing directory.
 
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), ...)