From ab4421747146aa7995f0cfb1a639c9121c82c915 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 8 Jan 2015 13:27:15 +0200 Subject: Implement tracing support Also use to-relative path translation in diagnostics. --- build/path | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'build/path') diff --git a/build/path b/build/path index ccc1b85..92832a1 100644 --- a/build/path +++ b/build/path @@ -218,6 +218,16 @@ namespace build bool root () const; + // Return true if *this is a sub-path of the specified path (i.e., + // the specified path is a prefix). Expects both paths to be + // normalized. + // + bool + sub (const basic_path& p) const + { + return path_.compare (0, p.path_.size (), p.path_) == 0; + } + public: // Return the path without the directory part. // @@ -249,6 +259,13 @@ namespace build basic_path base () const; + // Return a path relative to the specified path that is equivalent + // to *this. Throws invalid_path if a relative path cannot be derived + // (e.g., paths are on different drives on Windows). + // + basic_path + relative (basic_path) const; + public: // Normalize the path. This includes collapsing the '.' and '..' // directories if possible, collapsing multiple directory @@ -334,12 +351,14 @@ namespace build string_type path_; }; + /* template inline std::basic_ostream& operator<< (std::basic_ostream& os, basic_path const& p) { return os << p.string (); } + */ } #include -- cgit v1.1