diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-22 11:19:52 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-10-22 11:19:52 +0200 |
commit | 547a401ac73d21b769939a3244f991112dd9d2f7 (patch) | |
tree | 6ffeaba2df9ed2877ea423e7a51619e38bea854b /cutl/fs/path.ixx | |
parent | 13fe7d4568db4da0ec7dca7a69055f77933ce3f3 (diff) |
Add additional path functions
These include: absolute(), relative(), current(), complete(), and
normalize().
Diffstat (limited to 'cutl/fs/path.ixx')
-rw-r--r-- | cutl/fs/path.ixx | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/cutl/fs/path.ixx b/cutl/fs/path.ixx new file mode 100644 index 0000000..7a92110 --- /dev/null +++ b/cutl/fs/path.ixx @@ -0,0 +1,63 @@ +// file : cutl/fs/path.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#ifdef _WIN32 +# include <cctype> // std::tolower +# include <cwctype> // std::towlower +#endif + +namespace cutl +{ + namespace fs + { + template <typename C> + inline bool basic_path<C>:: + absolute () const + { +#ifdef _WIN32 + return path_.size () > 1 && path_[1] == ':'; +#else + return !path_.empty () && traits::is_separator (path_[0]); +#endif + } + + template <typename C> + inline bool basic_path<C>:: + root () const + { +#ifdef _WIN32 + return path_.size () == 2 && path_[1] == ':'; +#else + return path_.size () == 1 && traits::is_separator (path_[0]); +#endif + } + + template <typename C> + inline basic_path<C>& basic_path<C>:: + complete () + { + if (relative ()) + *this = current () / *this; + + return *this; + } + +#ifdef _WIN32 + template <> + inline char basic_path<char>:: + tolower (char c) + { + return std::tolower (c); + } + + template <> + inline wchar_t basic_path<wchar_t>:: + tolower (wchar_t c) + { + return std::towlower (c); + } +#endif + } +} |