aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/posix.ccm
diff options
context:
space:
mode:
Diffstat (limited to 'nihil.posix/posix.ccm')
-rw-r--r--nihil.posix/posix.ccm39
1 files changed, 39 insertions, 0 deletions
diff --git a/nihil.posix/posix.ccm b/nihil.posix/posix.ccm
new file mode 100644
index 0000000..e63ad6b
--- /dev/null
+++ b/nihil.posix/posix.ccm
@@ -0,0 +1,39 @@
+/*
+ * This source code is released into the public domain.
+ */
+
+module;
+
+#include <expected>
+#include <filesystem>
+#include <optional>
+#include <string>
+
+export module nihil.posix;
+
+import nihil.error;
+
+export import :argv;
+export import :ensure_dir;
+export import :exec;
+export import :fd;
+export import :getenv;
+export import :open;
+export import :process;
+export import :read_file;
+export import :rename;
+export import :spawn;
+export import :tempfile;
+export import :write_file;
+
+export namespace nihil {
+
+/*
+ * 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<fd>;
+
+} // namespace nihil