Skip to content

Commit 785f93f

Browse files
committed
Simplify create_directory preprocessor conditions
1 parent 3771c0c commit 785f93f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/directory.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,16 @@ fs::path create_directory(std::string_view prefix) {
7070
"prefix cannot contain a directory separator");
7171
}
7272

73-
#ifdef _WIN32
74-
fs::path::string_type path = make_path(prefix);
75-
#else
76-
std::string path = fs::temp_directory_path() / prefix;
77-
path += prefix.empty() ? "XXXXXX" : ".XXXXXX";
78-
#endif
79-
8073
std::error_code ec;
8174
#ifdef _WIN32
75+
fs::path path = make_path(prefix);
8276
if (!CreateDirectory(path.c_str(), nullptr)) {
8377
ec = std::error_code(GetLastError(), std::system_category());
8478
}
8579
#else
80+
std::string path = fs::temp_directory_path() / prefix;
81+
path += prefix.empty() ? "XXXXXX" : ".XXXXXX";
82+
8683
if (mkdtemp(path.data()) == nullptr) {
8784
ec = std::error_code(errno, std::system_category());
8885
}

0 commit comments

Comments
 (0)