aboutsummaryrefslogtreecommitdiff
path: root/libbutl/process.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-07-28 16:25:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-07-28 16:25:49 +0200
commit05a398f967bb030c6dbb9d6458340767325e46f4 (patch)
treefd4699b38809a9a24b0ee317a15f61118aa7b3e5 /libbutl/process.cxx
parent822059e4e69547f8e97a1cd219912f55826b0414 (diff)
Add ability to restrict executable search to PATH only
Diffstat (limited to 'libbutl/process.cxx')
-rw-r--r--libbutl/process.cxx16
1 files changed, 9 insertions, 7 deletions
diff --git a/libbutl/process.cxx b/libbutl/process.cxx
index 6f6ea8e..2260213 100644
--- a/libbutl/process.cxx
+++ b/libbutl/process.cxx
@@ -72,12 +72,12 @@ namespace butl
// process
//
static process_path
- path_search (const char*, const dir_path&);
+ path_search (const char*, const dir_path&, bool);
process_path process::
- path_search (const char* f, bool init, const dir_path& fb)
+ path_search (const char* f, bool init, const dir_path& fb, bool po)
{
- process_path r (try_path_search (f, init, fb));
+ process_path r (try_path_search (f, init, fb, po));
if (r.empty ())
throw process_error (ENOENT);
@@ -86,9 +86,9 @@ namespace butl
}
process_path process::
- try_path_search (const char* f, bool init, const dir_path& fb)
+ try_path_search (const char* f, bool init, const dir_path& fb, bool po)
{
- process_path r (butl::path_search (f, fb));
+ process_path r (butl::path_search (f, fb, po));
if (!init && !r.empty ())
{
@@ -150,7 +150,7 @@ namespace butl
#ifndef _WIN32
static process_path
- path_search (const char* f, const dir_path& fb)
+ path_search (const char* f, const dir_path& fb, bool)
{
// Note that there is a similar version for Win32.
@@ -614,7 +614,7 @@ namespace butl
#else // _WIN32
static process_path
- path_search (const char* f, const dir_path& fb)
+ path_search (const char* f, const dir_path& fb, bool po)
{
// Note that there is a similar version for Win32.
@@ -731,6 +731,7 @@ namespace butl
// The search order is documented in CreateProcess(). First we look in the
// directory of the parent executable.
//
+ if (!po)
{
char d[_MAX_PATH + 1];
DWORD n (GetModuleFileName (NULL, d, _MAX_PATH + 1));
@@ -778,6 +779,7 @@ namespace butl
// The recall path is the same as initial, though it might not be a bad
// idea to prepend .\ for clarity.
//
+ if (!po)
{
const string& d (traits::current_directory ());