From 05a398f967bb030c6dbb9d6458340767325e46f4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Jul 2017 16:25:49 +0200 Subject: Add ability to restrict executable search to PATH only --- libbutl/process.hxx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'libbutl/process.hxx') diff --git a/libbutl/process.hxx b/libbutl/process.hxx index cd692ca..3e1a990 100644 --- a/libbutl/process.hxx +++ b/libbutl/process.hxx @@ -313,8 +313,14 @@ namespace butl // This, for example, can be used to implement the Windows "search in the // parent executable's directory" semantics across platforms. // + // If path_only is true then only search in the PATH environment variable + // (or in CWD if there is a directory component) ignorting other places + // (like calling process' directory and, gasp, CWD on Windows). + // static process_path - path_search (const char*& args0, const dir_path& fallback = dir_path ()); + path_search (const char*& args0, + const dir_path& fallback = dir_path (), + bool path_only = false); // This version is primarily useful when you want to pre-search the // executable before creating the args[] array. In this case you will @@ -330,25 +336,31 @@ namespace butl // the same). // static process_path - path_search (const char* file, bool init, const dir_path& = dir_path ()); + path_search (const char* file, bool init, + const dir_path& = dir_path (), bool = false); static process_path - path_search (const std::string&, bool, const dir_path& = dir_path ()); + path_search (const std::string&, bool, + const dir_path& = dir_path (), bool = false); static process_path - path_search (const path&, bool, const dir_path& = dir_path ()); + path_search (const path&, bool, + const dir_path& = dir_path (), bool = false); // As above but if not found return empty process_path instead of // throwing. // static process_path - try_path_search (const char*, bool, const dir_path& = dir_path ()); + try_path_search (const char*, bool, + const dir_path& = dir_path (), bool = false); static process_path - try_path_search (const std::string&, bool, const dir_path& = dir_path ()); + try_path_search (const std::string&, bool, + const dir_path& = dir_path (), bool = false); static process_path - try_path_search (const path&, bool, const dir_path& = dir_path ()); + try_path_search (const path&, bool, + const dir_path& = dir_path (), bool = false); // Print process commmand line. If the number of elements is specified, // then it will print the piped multi-process command line, if present. -- cgit v1.1