blob: f2f5faa9d524e1d6c62a872d093890367c1994e8 (
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
24
25
26
27
|
// This source code is released into the public domain.
module;
#include <unistd.h>
export module nihil.posix:unlink;
// unlink: simple wrapper around ::unlink()
import nihil.std;
import nihil.util;
namespace nihil {
export [[nodiscard]] auto unlink(std::filesystem::path const &path)
-> std::expected<void, error>
{
auto guard = save_errno();
auto const ret = ::unlink(path.string().c_str());
if (ret == 0)
return {};
return std::unexpected(error(sys_error()));
}
} // namespace nihil
|