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/tempfile.ccm | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'nihil.posix/tempfile.ccm') diff --git a/nihil.posix/tempfile.ccm b/nihil.posix/tempfile.ccm index e1510e5..121c636 100644 --- a/nihil.posix/tempfile.ccm +++ b/nihil.posix/tempfile.ccm @@ -1,22 +1,15 @@ // This source code is released into the public domain. -module; - -// tempfile: create a temporary file. - -#include -#include -#include -#include -#include -#include - export module nihil.posix:tempfile; +import nihil.std; import nihil.error; import nihil.flagset; import :fd; import :getenv; import :open; +import :unlink; + +// tempfile: create a temporary file. namespace nihil { @@ -60,9 +53,7 @@ export struct temporary_file final throw std::logic_error("release() called on already-released tempfile"); if (!self.m_path.empty()) { - auto ec = std::error_code(); // ignore errors - remove(self.path(), ec); - + std::ignore = unlink(self.path()); self.m_path.clear(); } @@ -141,8 +132,7 @@ tempfile(tempfile_flags flags = tempfile_none) -> std::expected