A class that:
More...
A class that:
- On construction: switches the calling process's current working directory to the supplied directory
- On destruction: switches the calling process's working directory back to its original directory.
◆ CwdChanger() [1/2]
OpenSim::IO::CwdChanger::CwdChanger |
( |
const CwdChanger & |
| ) |
|
|
delete |
◆ CwdChanger() [2/2]
OpenSim::IO::CwdChanger::CwdChanger |
( |
CwdChanger && |
tmp | ) |
|
◆ ~CwdChanger()
OpenSim::IO::CwdChanger::~CwdChanger |
( |
| ) |
|
|
noexcept |
Destructs a CwdChanger instance.
The destructor switches the calling process's current working directory back to whatever it was before constructing the instance, unless:
- The instance was constructed with
noop()
: in this case, it does nothing
- The instance is an rvalue temporary: does nothing
◆ changeTo()
static CwdChanger OpenSim::IO::CwdChanger::changeTo |
( |
const std::string & |
newDir | ) |
|
|
static |
◆ changeToParentOf()
static CwdChanger OpenSim::IO::CwdChanger::changeToParentOf |
( |
const std::string & |
path | ) |
|
|
static |
Returns a CwdChanger that changes to the parent of path
.
This is useful when changing into a file's parent dir:
CwdChanger::changeToParentOf(xmlFile);
◆ noop()
static CwdChanger OpenSim::IO::CwdChanger::noop |
( |
| ) |
|
|
static |
Returns a CwdChanger that does nothing.
This is useful for conditional directory changing:
CwdChanger c = shouldSwitch ? CwdChanger::changeTo(p) : CwdChanger::noop();
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ restore()
void OpenSim::IO::CwdChanger::restore |
( |
| ) |
|
Prematurely change the current working directory back to its original location.
This is functionally equivalent to prematurely destructing the CwdChanger. After calling CwdChanger::restore(), the now-restored CwdChanger will become a noop instance that, when it destructs, will not attempt to change back to the original directory.
◆ stay()
void OpenSim::IO::CwdChanger::stay |
( |
| ) |
|
|
noexcept |
Release CwdChanger's control over the current working directory, such that the CwdChanger instance does not attempt to change back to its original directory on destruction.
The documentation for this class was generated from the following file: