aboutsummaryrefslogtreecommitdiff
path: root/build/path.txx
diff options
context:
space:
mode:
Diffstat (limited to 'build/path.txx')
-rw-r--r--build/path.txx28
1 files changed, 28 insertions, 0 deletions
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 <typename C>
+ const C* basic_path<C>::
+ 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 C>
typename basic_path<C>::string_type basic_path<C>::