diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-12-08 08:25:29 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-12-08 08:25:29 +0200 |
commit | 20e3aedeb7df742c38276fb41cae8f3eb027b6dd (patch) | |
tree | 3219377439099027c27b14bd8638d62ae7bc6db9 /build/path.ixx | |
parent | 985e8f5f28da87be779b80942577f088321024af (diff) |
Add filesystem path class
g++-4.9 -std=c++11 -I.. -o bd bd.cxx process.cxx timestamp.cxx path.cxx
Diffstat (limited to 'build/path.ixx')
-rw-r--r-- | build/path.ixx | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/build/path.ixx b/build/path.ixx new file mode 100644 index 0000000..f742060 --- /dev/null +++ b/build/path.ixx @@ -0,0 +1,68 @@ +// file : build/path.ixx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#ifdef _WIN32 +# include <cctype> // std::tolower +# include <cwctype> // std::towlower +#endif + +namespace build +{ +#ifdef _WIN32 + template <> + inline char path_traits<char>:: + tolower (char c) + { + return std::tolower (c); + } + + template <> + inline wchar_t path_traits<wchar_t>:: + tolower (wchar_t c) + { + return std::towlower (c); + } +#endif + + 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; + } + +#ifndef _WIN32 + template <typename C> + inline typename basic_path<C>::string_type basic_path<C>:: + posix_string () const + { + return string (); + } +#endif +} |