From a2d7181700ac64b8e7a4472ec26dfa253b38f188 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sat, 28 Jun 2025 19:25:55 +0100 Subject: split nihil into separate modules --- nihil.posix/nihil.posix.ccm | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 nihil.posix/nihil.posix.ccm (limited to 'nihil.posix/nihil.posix.ccm') diff --git a/nihil.posix/nihil.posix.ccm b/nihil.posix/nihil.posix.ccm new file mode 100644 index 0000000..9baecf8 --- /dev/null +++ b/nihil.posix/nihil.posix.ccm @@ -0,0 +1,45 @@ +/* + * This source code is released into the public domain. + */ + +module; + +#include +#include +#include +#include + +export module nihil.posix; + +import nihil.error; + +export import :argv; +export import :ensure_dir; +export import :exec; +export import :fd; +export import :open; +export import :process; +export import :read_file; +export import :rename; +export import :spawn; +export import :write_file; + +export namespace nihil { + +/* + * Find a variable by the given name in the environment by calling getenv_r(). + */ + +[[nodiscard]] auto getenv(std::string_view varname) + -> std::expected; + + +/* + * Find an executable in $PATH, open it with O_EXEC and return the fd. + * If $PATH is not set, uses _PATH_DEFPATH. If the file can't be found + * or opened, returns std::nullopt. + */ +[[nodiscard]] auto find_in_path(std::filesystem::path const &file) + -> std::optional; + +} // namespace nihil -- cgit v1.2.3