Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::filesystem::scoped_change_directory Class Reference

A RAII helper to temporarily change the working directory of the process. More...

Public Member Functions

 scoped_change_directory (null_terminated_string_view const new_path)
 Save the working directory and set it to the new path.
 
 scoped_change_directory (scoped_change_directory &&)=delete
 Not movable.
 
 scoped_change_directory (scoped_change_directory const &)=delete
 Not copyable.
 
 ~scoped_change_directory ()
 Restore the working directory to the value saved on construction if possible.
 
auto operator= (scoped_change_directory &&) -> scoped_change_directory &=delete
 Not movable.
 
auto operator= (scoped_change_directory const &) -> scoped_change_directory &=delete
 Not copyable.
 

Detailed Description

A RAII helper to temporarily change the working directory of the process.

The working directory is saved on construction, before being set to the new path. It is then restored to the old value on destruction.

Note
Use of this on multiple threads is inherently racy as there is only one working directory for the whole process.

Constructor & Destructor Documentation

◆ scoped_change_directory() [1/3]

arene::base::filesystem::scoped_change_directory::scoped_change_directory ( null_terminated_string_view const new_path)
explicit

Save the working directory and set it to the new path.

Parameters
new_pathThe new working directory
Exceptions
std::system_errorif an error occurs setting or retrieving the working directory

◆ ~scoped_change_directory()

arene::base::filesystem::scoped_change_directory::~scoped_change_directory ( )

Restore the working directory to the value saved on construction if possible.

Restore the old directory.

◆ scoped_change_directory() [2/3]

arene::base::filesystem::scoped_change_directory::scoped_change_directory ( scoped_change_directory const & )
delete

Not copyable.

◆ scoped_change_directory() [3/3]

arene::base::filesystem::scoped_change_directory::scoped_change_directory ( scoped_change_directory && )
delete

Not movable.

Member Function Documentation

◆ operator=() [1/2]

auto arene::base::filesystem::scoped_change_directory::operator= ( scoped_change_directory && ) -> scoped_change_directory &=delete
delete

Not movable.

◆ operator=() [2/2]

auto arene::base::filesystem::scoped_change_directory::operator= ( scoped_change_directory const & ) -> scoped_change_directory &=delete
delete

Not copyable.


The documentation for this class was generated from the following files: