fs/FileSystem: add CreateDirectoryNoThrow()

This commit is contained in:
Max Kellermann
2022-11-28 14:13:10 +01:00
parent 1da974e3fa
commit 4ded1ae67b
2 changed files with 11 additions and 1 deletions

View File

@@ -67,6 +67,16 @@ StatFile(Path file, struct stat &buf, bool follow_symlinks = true)
#endif
static inline bool
CreateDirectoryNoThrow(Path path) noexcept
{
#ifdef _WIN32
return CreateDirectory(path.c_str(), nullptr);
#else
return mkdir(path.c_str(), 0777);
#endif
}
/**
* Truncate a file that exists already. Throws std::system_error on
* error.