// file : build/path.ixx -*- C++ -*- // copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC // license : MIT; see accompanying LICENSE file #ifdef _WIN32 # include // std::tolower # include // std::towlower #endif namespace build { #ifdef _WIN32 template <> inline char path_traits:: tolower (char c) { return std::tolower (c); } template <> inline wchar_t path_traits:: tolower (wchar_t c) { return std::towlower (c); } #endif template inline bool basic_path:: absolute () const { #ifdef _WIN32 return path_.size () > 1 && path_[1] == ':'; #else return !path_.empty () && traits::is_separator (path_[0]); #endif } template inline bool basic_path:: root () const { #ifdef _WIN32 return path_.size () == 2 && path_[1] == ':'; #else return path_.size () == 1 && traits::is_separator (path_[0]); #endif } template inline basic_path& basic_path:: complete () { if (relative ()) *this = current () / *this; return *this; } template inline basic_path basic_path:: root_directory () const { return absolute () #ifdef _WIN32 ? path (path_, 2) #else ? path ("/") #endif : path (); } template inline basic_path basic_path:: base () const { size_type p (traits::find_extension (path_)); return p != string_type::npos ? basic_path (path_.c_str (), p) : *this; } template inline const C* basic_path:: extension () const { size_type p (traits::find_extension (path_)); return p != string_type::npos ? path_.c_str () + p + 1 : nullptr; } #ifndef _WIN32 template inline typename basic_path::string_type basic_path:: posix_string () const { return string (); } #endif }