SlHelpers
Toggle main menu visibility
Loading...
Searching...
No Matches
PushD.h
1
// SPDX-License-Identifier: GPL-2.0-only
2
3
#pragma once
4
5
#include <filesystem>
6
7
namespace
SlHelpers {
8
12
class
PushD {
13
public
:
14
PushD() =
delete
;
15
24
PushD
(
const
std::filesystem::path &dir, std::error_code &ec) {
25
origDir = std::filesystem::current_path(ec);
26
if
(!ec)
27
std::filesystem::current_path(dir, ec);
28
}
29
37
PushD
(
const
std::filesystem::path &dir) {
38
origDir = std::filesystem::current_path();
39
std::filesystem::current_path(dir);
40
}
41
~PushD
() { std::filesystem::current_path(origDir); }
42
private
:
43
std::filesystem::path origDir;
44
};
45
46
}
SlHelpers::PushD
Change to a directory while this object lives, then change back.
Definition
PushD.h:12
SlHelpers::PushD::PushD
PushD(const std::filesystem::path &dir)
Change to directory dir and throw an exception on error.
Definition
PushD.h:37
SlHelpers::PushD::PushD
PushD(const std::filesystem::path &dir, std::error_code &ec)
Change to directory dir.
Definition
PushD.h:24
include
helpers
PushD.h
Generated by
1.17.0