From 882583f64e517ab232edb6bbb7433631c655c9da Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 7 Nov 2019 11:12:43 +0200 Subject: Initial work on path_name use for `-` to stdin/stdout translation --- libbuild2/utility.cxx | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) (limited to 'libbuild2/utility.cxx') diff --git a/libbuild2/utility.cxx b/libbuild2/utility.cxx index 7f40688..b7637f5 100644 --- a/libbuild2/utility.cxx +++ b/libbuild2/utility.cxx @@ -8,7 +8,7 @@ #include // ENOENT #include // strlen(), str[n]cmp() -#include // cin cout cerr +#include // cerr #include #include @@ -45,6 +45,12 @@ namespace std } ostream& + operator<< (ostream& os, const ::butl::path_name& pn) + { + return pn.name ? (os << *pn.name) : (os << *pn.path); + } + + ostream& operator<< (ostream& os, const ::butl::process_path& p) { using namespace build2; @@ -100,36 +106,6 @@ namespace build2 dir_path home; const dir_path* relative_base = &work; - istream& - open_file_or_stdin (const path& f, ifdstream& ifs) - { - if (f.string () != "-") - { - ifs.open (f); - return ifs; - } - else - { - cin.exceptions (ifdstream::failbit | ifdstream::badbit); - return cin; - } - } - - ostream& - open_file_or_stdout (const path& f, ofdstream& ofs) - { - if (f.string () != "-") - { - ofs.open (f); - return ofs; - } - else - { - cout.exceptions (ofdstream::failbit | ofdstream::badbit); - return cout; - } - } - path relative (const path_target& t) { @@ -141,7 +117,7 @@ namespace build2 string diag_relative (const path& p, bool cur) { - if (p.string () == "-") + if (p.string () == "-") // @@ PATH_NAME: remove return ""; const path& b (*relative_base); -- cgit v1.1