pstore2
path.hpp
Go to the documentation of this file.
1 //===- include/pstore/os/path.hpp -------------------------*- mode: C++ -*-===//
2 //* _ _ *
3 //* _ __ __ _| |_| |__ *
4 //* | '_ \ / _` | __| '_ \ *
5 //* | |_) | (_| | |_| | | | *
6 //* | .__/ \__,_|\__|_| |_| *
7 //* |_| *
8 //===----------------------------------------------------------------------===//
9 //
10 // Part of the pstore project, under the Apache License v2.0 with LLVM Exceptions.
11 // See https://github.com/SNSystems/pstore/blob/master/LICENSE.txt for license
12 // information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //===----------------------------------------------------------------------===//
18 
19 #ifndef PSTORE_OS_PATH_HPP
20 #define PSTORE_OS_PATH_HPP
21 
22 #include <initializer_list>
23 #include <string>
24 #include <utility>
25 
26 #if defined(_WIN32)
27 # define PSTORE_PLATFORM_NS win32
28 #else
29 # define PSTORE_PLATFORM_NS posix
30 #endif
31 
32 namespace pstore {
35  namespace path {
36 
38  namespace posix {
39  std::pair<std::string, std::string> split_drive (std::string const & path);
40  std::string dir_name (std::string const & path);
41  std::string base_name (std::string const & path);
42 
43  std::string join (std::string const & path,
44  std::initializer_list<std::string> const & paths);
45  inline std::string join (std::string const & path, std::string const & b) {
46  return join (path, {b});
47  }
48  } // namespace posix
49 
51  namespace win32 {
52  std::pair<std::string, std::string> split_drive (std::string const & path);
53  std::string dir_name (std::string const & path);
54  std::string base_name (std::string const & path);
55 
56  std::string join (std::string const & path,
57  std::initializer_list<std::string> const & paths);
58  inline std::string join (std::string const & path, std::string const & b) {
59  return join (path, {b});
60  }
61  } // namespace win32
62 
63  inline std::pair<std::string, std::string> split_drive (std::string const & path) {
64  return PSTORE_PLATFORM_NS::split_drive (path);
65  }
66 
67  inline std::string base_name (std::string const & path) {
68  return PSTORE_PLATFORM_NS::base_name (path);
69  }
70 
71  inline std::string dir_name (std::string const & path) {
72  return PSTORE_PLATFORM_NS::dir_name (path);
73  }
74 
75 
86 
87  inline std::string join (std::string const & path,
88  std::initializer_list<std::string> const & paths) {
89  return PSTORE_PLATFORM_NS::join (path, paths);
90  }
91 
92  inline std::string join (std::string const & path, std::string const & b) {
93  return PSTORE_PLATFORM_NS::join (path, b);
94  }
96 
97 
98  } // namespace path
99 } // namespace pstore
100 
101 #undef PSTORE_PLATFORM_NS
102 
103 #endif // PSTORE_OS_PATH_HPP
Definition: nonpod2.cpp:40