blob: 6b640b1bd1b9714bb6fb2329d70554b6d5a5bd46 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// This source code is released into the public domain.
export module nihil.posix:rename;
import nihil.std;
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<void, error>
{
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
|