From 4d79758a845d3cd64f0153d60abb88d3ae4c2a68 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Aug 2016 12:51:24 +0200 Subject: Extend process search with pre-search support, other minor improvements --- butl/process.ixx | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'butl/process.ixx') diff --git a/butl/process.ixx b/butl/process.ixx index 59ac60c..264f77c 100644 --- a/butl/process.ixx +++ b/butl/process.ixx @@ -7,6 +7,20 @@ namespace butl { inline process_path:: + ~process_path () + { + if (args0_ != nullptr) + *args0_ = initial; + } + + inline process_path:: + process_path (const char* i, path&& r, path&& e) + : initial (i), + recall (std::move (r)), + effect (std::move (e)), + args0_ (nullptr) {} + + inline process_path:: process_path (process_path&& p) : initial (p.initial), recall (std::move (p.recall)), @@ -35,6 +49,32 @@ namespace butl return *this; } + inline const char* process_path:: + recall_string () const + { + return recall.empty () ? initial : recall.string ().c_str (); + } + + inline const char* process_path:: + effect_string () const + { + return effect.empty () ? recall_string () : effect.string ().c_str (); + } + + inline process_path process:: + path_search (const char*& a0, const dir_path& fb) + { + process_path r (path_search (a0, true, fb)); + + if (!r.recall.empty ()) + { + r.args0_ = &a0; + a0 = r.recall.string ().c_str (); + } + + return r; + } + inline process:: process () : handle (0), -- cgit v1.1