Skip to content

Commit 4a1b7cb

Browse files
author
Daniel Kroening
committed
added create_directory(path)
This replaces mkdir(...), which differs on Unix and Windows.
1 parent 5c49b12 commit 4a1b7cb

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/util/file_util.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,13 @@ bool is_directory(const std::string &path)
193193

194194
#endif
195195
}
196+
197+
bool create_directory(const std::string &path)
198+
{
199+
#ifdef _WIN32
200+
return _mkdir(path.c_str()) == 0;
201+
#else
202+
// the umask matches what std::filesystem::create_directory does
203+
return mkdir(path.c_str(), 0777) == 0;
204+
#endif
205+
}

src/util/file_util.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ std::string concat_dir_file(const std::string &directory,
2727
// C++17 will allow us to use std::filesystem::is_directory
2828
bool is_directory(const std::string &path);
2929

30+
/// Create a directory with given path
31+
/// C++17 will allow us to use std::filesystem::create_directory
32+
/// \return true iff the directory was created
33+
bool create_directory(const std::string &path);
34+
3035
#endif // CPROVER_UTIL_FILE_UTIL_H

0 commit comments

Comments
 (0)