From 2e2d1bd3b6c7776b77c33b94f30ead89367a71e6 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Tue, 1 Jul 2025 17:07:04 +0100 Subject: add nihil.std --- nihil.posix/unlink.ccm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 nihil.posix/unlink.ccm (limited to 'nihil.posix/unlink.ccm') diff --git a/nihil.posix/unlink.ccm b/nihil.posix/unlink.ccm new file mode 100644 index 0000000..d6c47cd --- /dev/null +++ b/nihil.posix/unlink.ccm @@ -0,0 +1,28 @@ +// This source code is released into the public domain. +module; + +#include + +export module nihil.posix:unlink; + +// unlink: simple wrapper around ::unlink() + +import nihil.std; +import nihil.error; +import nihil.util; + +namespace nihil { + +export [[nodiscard]] auto unlink(std::filesystem::path const &path) + -> std::expected +{ + auto guard = save_errno(); + + auto const ret = ::unlink(path.string().c_str()); + if (ret == 0) + return {}; + + return std::unexpected(error(sys_error())); +} + +} // namespace nihil -- cgit v1.2.3