aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/open_in_path.ccm
blob: 1fae56b5209dd77a2efad3cb0cb5fd7e8bf1d5a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * This source code is released into the public domain.
 */

module;

#include <filesystem>
#include <optional>

export module nihil.posix:find_in_path;

import nihil.error;
import :fd;

namespace nihil {

/*
 * Find an executable in $PATH and open it with O_EXEC.  If $PATH is not set, uses _PATH_DEFPATH.
 * If the file can't be found or opened, returns std::nullopt.
 */
export [[nodiscard]] auto open_in_path(std::filesystem::path const &file) -> std::optional<fd>;

} // namespace nihil