// This source code is released into the public domain. export module nihil.posix:rename; import nihil.std; import nihil.error; import nihil.util; namespace nihil { // Rename a file (or directory). export [[nodiscard]] auto rename(std::filesystem::path const &oldp, std::filesystem::path const &newp) -> std::expected { auto guard = save_errno(); auto const ret = std::rename(oldp.string().c_str(), newp.string().c_str()); if (ret == -1) return std::unexpected(error(sys_error())); return {}; } } // namespace nihil