diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-07-01 17:07:04 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-07-01 17:07:04 +0100 |
| commit | 2e2d1bd3b6c7776b77c33b94f30ead89367a71e6 (patch) | |
| tree | 54d37ffadf8e677938d9b7a28e4e9b71be1e75c1 /nihil.posix/tempfile.ccm | |
| parent | 36427c0966faa7aecd586b397ed9b845f18172f5 (diff) | |
| download | nihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.gz nihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.bz2 | |
add nihil.std
Diffstat (limited to 'nihil.posix/tempfile.ccm')
| -rw-r--r-- | nihil.posix/tempfile.ccm | 22 |
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)); } |
