// 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 { auto err = std::error_code(); std::filesystem::create_directories(dir, err); if (err) return std::unexpected(error(err)); return {}; } } // namespace nihil