aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/utility.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-11-07 11:12:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-11-07 11:12:43 +0200
commit882583f64e517ab232edb6bbb7433631c655c9da (patch)
tree3d0e8e16c20b1346cb34961c7f908b07427e9632 /libbuild2/utility.cxx
parentcf18da3ac461087ccffd31222dbe4fa2e6428d56 (diff)
Initial work on path_name use for `-` to stdin/stdout translation
Diffstat (limited to 'libbuild2/utility.cxx')
-rw-r--r--libbuild2/utility.cxx40
1 files changed, 8 insertions, 32 deletions
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 <cerrno> // ENOENT
#include <cstring> // strlen(), str[n]cmp()
-#include <iostream> // cin cout cerr
+#include <iostream> // cerr
#include <libbuild2/target.hxx>
#include <libbuild2/context.hxx>
@@ -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 "<stdin>";
const path& b (*relative_base);