aboutsummaryrefslogtreecommitdiff
path: root/cutl/fs/path.ixx
blob: 7a92110d5a7fa5e70027ff44339479c9876edcff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
  }
}