From ce8a94e6a76097ef7eeb34df4257991a20599712 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 14 Jan 2015 11:39:21 +0200 Subject: Track file extension in target, prerequisite --- build/path.txx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'build/path.txx') diff --git a/build/path.txx b/build/path.txx index 3e952d8..f576870 100644 --- a/build/path.txx +++ b/build/path.txx @@ -62,6 +62,34 @@ namespace build return *this; } + template + const C* basic_path:: + extension () const + { + size_type i (path_.size ()); + + for (; i > 0; --i) + { + if (path_[i - 1] == '.') + break; + + if (traits::is_separator (path_[i - 1])) + { + i = 0; + break; + } + } + + // Weed out paths like ".txt" and "/.txt" + // + if (i > 1 && !traits::is_separator (path_[i - 2])) + { + return path_.c_str () + i; + } + else + return nullptr; + } + #ifdef _WIN32 template typename basic_path::string_type basic_path:: -- cgit v1.1