aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/tempfile.ccm
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-07-01 17:07:04 +0100
committerLexi Winter <lexi@le-fay.org>2025-07-01 17:07:04 +0100
commit2e2d1bd3b6c7776b77c33b94f30ead89367a71e6 (patch)
tree54d37ffadf8e677938d9b7a28e4e9b71be1e75c1 /nihil.posix/tempfile.ccm
parent36427c0966faa7aecd586b397ed9b845f18172f5 (diff)
downloadnihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.gz
nihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.bz2
add nihil.std
Diffstat (limited to 'nihil.posix/tempfile.ccm')
-rw-r--r--nihil.posix/tempfile.ccm22
1 files changed, 6 insertions, 16 deletions
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 <algorithm>
-#include <cstdint>
-#include <expected>
-#include <filesystem>
-#include <random>
-#include <string>
-
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<temporary_file,
}
if (flags & tempfile_unlink) {
- auto ec = std::error_code();
- remove(filename, ec);
+ std::ignore = unlink(filename);
return temporary_file(std::move(*fd));
}