blob: 65347363dd4b653af425bfadd08d28646c7744e0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// This source code is released into the public domain.
export module nihil.posix:ensure_dir;
import nihil.std;
import nihil.core;
namespace nihil {
// Create the given directory and any parent directories.
export [[nodiscard]] auto
ensure_dir(std::filesystem::path const &dir) -> std::expected<void, error>
{
auto err = std::error_code();
std::filesystem::create_directories(dir, err);
if (err)
return std::unexpected(error(err));
return {};
}
} // namespace nihil
|