path.hpp 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835
  1. // filesystem path.hpp ---------------------------------------------------------------//
  2. // Copyright Vladimir Prus 2002
  3. // Copyright Beman Dawes 2002-2005, 2009
  4. // Copyright Andrey Semashev 2021-2023
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // See http://www.boost.org/LICENSE_1_0.txt
  7. // Library home page: http://www.boost.org/libs/filesystem
  8. // path::stem(), extension(), and replace_extension() are based on
  9. // basename(), extension(), and change_extension() from the original
  10. // filesystem/convenience.hpp header by Vladimir Prus.
  11. #ifndef BOOST_FILESYSTEM_PATH_HPP
  12. #define BOOST_FILESYSTEM_PATH_HPP
  13. #include <boost/assert.hpp>
  14. #include <boost/filesystem/config.hpp>
  15. #include <boost/filesystem/detail/path_traits.hpp>
  16. #include <boost/iterator/iterator_facade.hpp>
  17. #include <boost/iterator/iterator_categories.hpp>
  18. #include <boost/core/enable_if.hpp>
  19. #include <boost/io/quoted.hpp>
  20. #include <boost/functional/hash_fwd.hpp>
  21. #include <boost/type_traits/negation.hpp>
  22. #include <boost/type_traits/conjunction.hpp>
  23. #include <boost/type_traits/disjunction.hpp>
  24. #include <boost/type_traits/is_same.hpp>
  25. #include <boost/type_traits/remove_cv.hpp>
  26. #include <cstddef>
  27. #include <iosfwd>
  28. #include <locale>
  29. #include <string>
  30. #include <iterator>
  31. #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
  32. #include <string_view>
  33. #endif
  34. #include <boost/filesystem/detail/header.hpp> // must be the last #include
  35. namespace boost {
  36. namespace filesystem {
  37. class path;
  38. namespace path_detail { // intentionally don't use filesystem::detail to not bring internal Boost.Filesystem functions into ADL via path_constants
  39. template< typename Char, Char Separator, Char PreferredSeparator, Char Dot >
  40. struct path_constants
  41. {
  42. typedef path_constants< Char, Separator, PreferredSeparator, Dot > path_constants_base;
  43. typedef Char value_type;
  44. static BOOST_CONSTEXPR_OR_CONST value_type separator = Separator;
  45. static BOOST_CONSTEXPR_OR_CONST value_type preferred_separator = PreferredSeparator;
  46. static BOOST_CONSTEXPR_OR_CONST value_type dot = Dot;
  47. };
  48. #if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
  49. template< typename Char, Char Separator, Char PreferredSeparator, Char Dot >
  50. BOOST_CONSTEXPR_OR_CONST typename path_constants< Char, Separator, PreferredSeparator, Dot >::value_type
  51. path_constants< Char, Separator, PreferredSeparator, Dot >::separator;
  52. template< typename Char, Char Separator, Char PreferredSeparator, Char Dot >
  53. BOOST_CONSTEXPR_OR_CONST typename path_constants< Char, Separator, PreferredSeparator, Dot >::value_type
  54. path_constants< Char, Separator, PreferredSeparator, Dot >::preferred_separator;
  55. template< typename Char, Char Separator, Char PreferredSeparator, Char Dot >
  56. BOOST_CONSTEXPR_OR_CONST typename path_constants< Char, Separator, PreferredSeparator, Dot >::value_type
  57. path_constants< Char, Separator, PreferredSeparator, Dot >::dot;
  58. #endif
  59. class path_iterator;
  60. class path_reverse_iterator;
  61. } // namespace path_detail
  62. namespace detail {
  63. struct path_algorithms
  64. {
  65. // A struct that denotes a contiguous range of characters in a string. A lightweight alternative to string_view.
  66. struct substring
  67. {
  68. std::size_t pos;
  69. std::size_t size;
  70. };
  71. typedef path_traits::path_native_char_type value_type;
  72. typedef std::basic_string< value_type > string_type;
  73. static bool has_filename_v3(path const& p);
  74. static bool has_filename_v4(path const& p);
  75. BOOST_FILESYSTEM_DECL static path filename_v3(path const& p);
  76. static path filename_v4(path const& p);
  77. BOOST_FILESYSTEM_DECL static path stem_v3(path const& p);
  78. BOOST_FILESYSTEM_DECL static path stem_v4(path const& p);
  79. BOOST_FILESYSTEM_DECL static path extension_v3(path const& p);
  80. static path extension_v4(path const& p);
  81. BOOST_FILESYSTEM_DECL static void remove_filename_v3(path& p);
  82. BOOST_FILESYSTEM_DECL static void remove_filename_v4(path& p);
  83. BOOST_FILESYSTEM_DECL static void replace_extension_v3(path& p, path const& new_extension);
  84. BOOST_FILESYSTEM_DECL static void replace_extension_v4(path& p, path const& new_extension);
  85. BOOST_FILESYSTEM_DECL static path lexically_normal_v3(path const& p);
  86. BOOST_FILESYSTEM_DECL static path lexically_normal_v4(path const& p);
  87. BOOST_FILESYSTEM_DECL static int compare_v3(path const& left, path const& right);
  88. BOOST_FILESYSTEM_DECL static int compare_v4(path const& left, path const& right);
  89. BOOST_FILESYSTEM_DECL static void append_v3(path& p, const value_type* b, const value_type* e);
  90. BOOST_FILESYSTEM_DECL static void append_v4(path& p, const value_type* b, const value_type* e);
  91. static void append_v4(path& left, path const& right);
  92. // Returns: If separator is to be appended, m_pathname.size() before append. Otherwise 0.
  93. // Note: An append is never performed if size()==0, so a returned 0 is unambiguous.
  94. BOOST_FILESYSTEM_DECL static string_type::size_type append_separator_if_needed(path& p);
  95. BOOST_FILESYSTEM_DECL static void erase_redundant_separator(path& p, string_type::size_type sep_pos);
  96. BOOST_FILESYSTEM_DECL static string_type::size_type find_root_name_size(path const& p);
  97. BOOST_FILESYSTEM_DECL static string_type::size_type find_root_path_size(path const& p);
  98. BOOST_FILESYSTEM_DECL static substring find_root_directory(path const& p);
  99. BOOST_FILESYSTEM_DECL static substring find_relative_path(path const& p);
  100. BOOST_FILESYSTEM_DECL static string_type::size_type find_parent_path_size(path const& p);
  101. BOOST_FILESYSTEM_DECL static string_type::size_type find_filename_v4_size(path const& p);
  102. BOOST_FILESYSTEM_DECL static string_type::size_type find_extension_v4_size(path const& p);
  103. BOOST_FILESYSTEM_DECL static int lex_compare_v3
  104. (
  105. path_detail::path_iterator first1, path_detail::path_iterator const& last1,
  106. path_detail::path_iterator first2, path_detail::path_iterator const& last2
  107. );
  108. BOOST_FILESYSTEM_DECL static int lex_compare_v4
  109. (
  110. path_detail::path_iterator first1, path_detail::path_iterator const& last1,
  111. path_detail::path_iterator first2, path_detail::path_iterator const& last2
  112. );
  113. BOOST_FILESYSTEM_DECL static void increment_v3(path_detail::path_iterator& it);
  114. BOOST_FILESYSTEM_DECL static void increment_v4(path_detail::path_iterator& it);
  115. BOOST_FILESYSTEM_DECL static void decrement_v3(path_detail::path_iterator& it);
  116. BOOST_FILESYSTEM_DECL static void decrement_v4(path_detail::path_iterator& it);
  117. };
  118. } // namespace detail
  119. //------------------------------------------------------------------------------------//
  120. // //
  121. // class path //
  122. // //
  123. //------------------------------------------------------------------------------------//
  124. class path :
  125. public filesystem::path_detail::path_constants<
  126. #ifdef BOOST_WINDOWS_API
  127. detail::path_traits::path_native_char_type, L'/', L'\\', L'.'
  128. #else
  129. detail::path_traits::path_native_char_type, '/', '/', '.'
  130. #endif
  131. >
  132. {
  133. friend class path_detail::path_iterator;
  134. friend class path_detail::path_reverse_iterator;
  135. friend struct detail::path_algorithms;
  136. public:
  137. // value_type is the character type used by the operating system API to
  138. // represent paths.
  139. typedef detail::path_algorithms::value_type value_type;
  140. typedef detail::path_algorithms::string_type string_type;
  141. typedef detail::path_traits::codecvt_type codecvt_type;
  142. // ----- character encoding conversions -----
  143. // Following the principle of least astonishment, path input arguments
  144. // passed to or obtained from the operating system via objects of
  145. // class path behave as if they were directly passed to or
  146. // obtained from the O/S API, unless conversion is explicitly requested.
  147. //
  148. // POSIX specfies that path strings are passed unchanged to and from the
  149. // API. Note that this is different from the POSIX command line utilities,
  150. // which convert according to a locale.
  151. //
  152. // Thus for POSIX, char strings do not undergo conversion. wchar_t strings
  153. // are converted to/from char using the path locale or, if a conversion
  154. // argument is given, using a conversion object modeled on
  155. // std::wstring_convert.
  156. //
  157. // The path locale, which is global to the thread, can be changed by the
  158. // imbue() function. It is initialized to an implementation defined locale.
  159. //
  160. // For Windows, wchar_t strings do not undergo conversion. char strings
  161. // are converted using the "ANSI" or "OEM" code pages, as determined by
  162. // the AreFileApisANSI() function, or, if a conversion argument is given,
  163. // using a conversion object modeled on std::wstring_convert.
  164. //
  165. // See m_pathname comments for further important rationale.
  166. // TODO: rules needed for operating systems that use / or .
  167. // differently, or format directory paths differently from file paths.
  168. //
  169. // **********************************************************************************
  170. //
  171. // More work needed: How to handle an operating system that may have
  172. // slash characters or dot characters in valid filenames, either because
  173. // it doesn't follow the POSIX standard, or because it allows MBCS
  174. // filename encodings that may contain slash or dot characters. For
  175. // example, ISO/IEC 2022 (JIS) encoding which allows switching to
  176. // JIS x0208-1983 encoding. A valid filename in this set of encodings is
  177. // 0x1B 0x24 0x42 [switch to X0208-1983] 0x24 0x2F [U+304F Kiragana letter KU]
  178. // ^^^^
  179. // Note that 0x2F is the ASCII slash character
  180. //
  181. // **********************************************************************************
  182. // Supported source arguments: half-open iterator range, container, c-array,
  183. // and single pointer to null terminated string.
  184. // All source arguments except pointers to null terminated byte strings support
  185. // multi-byte character strings which may have embedded nulls. Embedded null
  186. // support is required for some Asian languages on Windows.
  187. // "const codecvt_type& cvt=codecvt()" default arguments are not used because this
  188. // limits the impact of locale("") initialization failures on POSIX systems to programs
  189. // that actually depend on locale(""). It further ensures that exceptions thrown
  190. // as a result of such failues occur after main() has started, so can be caught.
  191. private:
  192. //! Assignment operation
  193. class assign_op
  194. {
  195. private:
  196. path& m_self;
  197. public:
  198. typedef void result_type;
  199. explicit assign_op(path& self) BOOST_NOEXCEPT : m_self(self) {}
  200. result_type operator() (const value_type* source, const value_type* source_end, const codecvt_type* = NULL) const
  201. {
  202. m_self.m_pathname.assign(source, source_end);
  203. }
  204. template< typename OtherChar >
  205. result_type operator() (const OtherChar* source, const OtherChar* source_end, const codecvt_type* cvt = NULL) const
  206. {
  207. m_self.m_pathname.clear();
  208. detail::path_traits::convert(source, source_end, m_self.m_pathname, cvt);
  209. }
  210. };
  211. //! Concatenation operation
  212. class concat_op
  213. {
  214. private:
  215. path& m_self;
  216. public:
  217. typedef void result_type;
  218. explicit concat_op(path& self) BOOST_NOEXCEPT : m_self(self) {}
  219. result_type operator() (const value_type* source, const value_type* source_end, const codecvt_type* = NULL) const
  220. {
  221. m_self.m_pathname.append(source, source_end);
  222. }
  223. template< typename OtherChar >
  224. result_type operator() (const OtherChar* source, const OtherChar* source_end, const codecvt_type* cvt = NULL) const
  225. {
  226. detail::path_traits::convert(source, source_end, m_self.m_pathname, cvt);
  227. }
  228. };
  229. //! Path appending operation
  230. class append_op
  231. {
  232. private:
  233. path& m_self;
  234. public:
  235. typedef void result_type;
  236. explicit append_op(path& self) BOOST_NOEXCEPT : m_self(self) {}
  237. BOOST_FORCEINLINE result_type operator() (const value_type* source, const value_type* source_end, const codecvt_type* = NULL) const
  238. {
  239. m_self.append(source, source_end);
  240. }
  241. template< typename OtherChar >
  242. BOOST_FORCEINLINE result_type operator() (const OtherChar* source, const OtherChar* source_end, const codecvt_type* cvt = NULL) const
  243. {
  244. string_type src;
  245. detail::path_traits::convert(source, source_end, src, cvt);
  246. m_self.append(src.data(), src.data() + src.size());
  247. }
  248. };
  249. //! Path comparison operation
  250. class compare_op
  251. {
  252. private:
  253. path const& m_self;
  254. public:
  255. typedef int result_type;
  256. explicit compare_op(path const& self) BOOST_NOEXCEPT : m_self(self) {}
  257. result_type operator() (const value_type* source, const value_type* source_end, const codecvt_type* = NULL) const;
  258. template< typename OtherChar >
  259. result_type operator() (const OtherChar* source, const OtherChar* source_end, const codecvt_type* cvt = NULL) const;
  260. };
  261. public:
  262. typedef path_detail::path_iterator iterator;
  263. typedef iterator const_iterator;
  264. typedef path_detail::path_reverse_iterator reverse_iterator;
  265. typedef reverse_iterator const_reverse_iterator;
  266. public:
  267. // ----- constructors -----
  268. path() BOOST_NOEXCEPT {}
  269. path(path const& p) : m_pathname(p.m_pathname) {}
  270. path(path const& p, codecvt_type const&) : m_pathname(p.m_pathname) {}
  271. path(const value_type* s) : m_pathname(s) {}
  272. path(const value_type* s, codecvt_type const&) : m_pathname(s) {}
  273. path(string_type const& s) : m_pathname(s) {}
  274. path(string_type const& s, codecvt_type const&) : m_pathname(s) {}
  275. #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
  276. path(std::basic_string_view< value_type > const& s) : m_pathname(s) {}
  277. path(std::basic_string_view< value_type > const& s, codecvt_type const&) : m_pathname(s) {}
  278. #endif
  279. #if !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
  280. template<
  281. typename Source,
  282. typename = typename boost::enable_if_c<
  283. boost::conjunction<
  284. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >,
  285. boost::negation< detail::path_traits::is_native_path_source< typename boost::remove_cv< Source >::type > >
  286. >::value
  287. >::type
  288. >
  289. path(Source const& source)
  290. #else
  291. template< typename Source >
  292. path(Source const& source, typename boost::enable_if_c<
  293. boost::conjunction<
  294. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >,
  295. boost::negation< detail::path_traits::is_native_path_source< typename boost::remove_cv< Source >::type > >
  296. >::value
  297. >::type* = NULL)
  298. #endif
  299. {
  300. assign(source);
  301. }
  302. #if !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
  303. template<
  304. typename Source,
  305. typename = typename boost::enable_if_c<
  306. boost::conjunction<
  307. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >,
  308. boost::negation< detail::path_traits::is_native_path_source< typename boost::remove_cv< Source >::type > >
  309. >::value
  310. >::type
  311. >
  312. explicit path(Source const& source, codecvt_type const& cvt)
  313. #else
  314. template< typename Source >
  315. explicit path(Source const& source, codecvt_type const& cvt, typename boost::enable_if_c<
  316. boost::conjunction<
  317. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >,
  318. boost::negation< detail::path_traits::is_native_path_source< typename boost::remove_cv< Source >::type > >
  319. >::value
  320. >::type* = NULL)
  321. #endif
  322. {
  323. assign(source, cvt);
  324. }
  325. // As of October 2015 the interaction between noexcept and =default is so troublesome
  326. // for VC++, GCC, and probably other compilers, that =default is not used with noexcept
  327. // functions. GCC is not even consistent for the same release on different platforms.
  328. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  329. path(path&& p) BOOST_NOEXCEPT : m_pathname(static_cast< string_type&& >(p.m_pathname))
  330. {
  331. }
  332. path(path&& p, codecvt_type const&) BOOST_NOEXCEPT : m_pathname(static_cast< string_type&& >(p.m_pathname))
  333. {
  334. }
  335. path& operator=(path&& p) BOOST_NOEXCEPT
  336. {
  337. m_pathname = static_cast< string_type&& >(p.m_pathname);
  338. return *this;
  339. }
  340. path& assign(path&& p) BOOST_NOEXCEPT
  341. {
  342. m_pathname = static_cast< string_type&& >(p.m_pathname);
  343. return *this;
  344. }
  345. path& assign(path&& p, codecvt_type const&) BOOST_NOEXCEPT
  346. {
  347. m_pathname = static_cast< string_type&& >(p.m_pathname);
  348. return *this;
  349. }
  350. path(string_type&& s) BOOST_NOEXCEPT : m_pathname(static_cast< string_type&& >(s))
  351. {
  352. }
  353. path(string_type&& s, codecvt_type const&) BOOST_NOEXCEPT : m_pathname(static_cast< string_type&& >(s))
  354. {
  355. }
  356. path& operator=(string_type&& p) BOOST_NOEXCEPT
  357. {
  358. m_pathname = static_cast< string_type&& >(p);
  359. return *this;
  360. }
  361. path& assign(string_type&& p) BOOST_NOEXCEPT
  362. {
  363. m_pathname = static_cast< string_type&& >(p);
  364. return *this;
  365. }
  366. path& assign(string_type&& p, codecvt_type const&) BOOST_NOEXCEPT
  367. {
  368. m_pathname = static_cast< string_type&& >(p);
  369. return *this;
  370. }
  371. #endif
  372. path(const value_type* begin, const value_type* end) : m_pathname(begin, end) {}
  373. path(const value_type* begin, const value_type* end, codecvt_type const&) : m_pathname(begin, end) {}
  374. #if !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
  375. template<
  376. typename InputIterator,
  377. typename = typename boost::enable_if_c<
  378. boost::conjunction<
  379. detail::path_traits::is_path_source_iterator< InputIterator >,
  380. boost::negation< detail::path_traits::is_native_char_ptr< InputIterator > >
  381. >::value
  382. >::type
  383. >
  384. path(InputIterator begin, InputIterator end)
  385. #else
  386. template< typename InputIterator >
  387. path(InputIterator begin, InputIterator end, typename boost::enable_if_c<
  388. boost::conjunction<
  389. detail::path_traits::is_path_source_iterator< InputIterator >,
  390. boost::negation< detail::path_traits::is_native_char_ptr< InputIterator > >
  391. >::value
  392. >::type* = NULL)
  393. #endif
  394. {
  395. if (begin != end)
  396. {
  397. typedef std::basic_string< typename std::iterator_traits< InputIterator >::value_type > source_t;
  398. source_t source(begin, end);
  399. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  400. assign(static_cast< source_t&& >(source));
  401. #else
  402. assign(source);
  403. #endif
  404. }
  405. }
  406. #if !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
  407. template<
  408. typename InputIterator,
  409. typename = typename boost::enable_if_c<
  410. boost::conjunction<
  411. detail::path_traits::is_path_source_iterator< InputIterator >,
  412. boost::negation< detail::path_traits::is_native_char_ptr< InputIterator > >
  413. >::value
  414. >::type
  415. >
  416. path(InputIterator begin, InputIterator end, codecvt_type const& cvt)
  417. #else
  418. template< typename InputIterator >
  419. path(InputIterator begin, InputIterator end, codecvt_type const& cvt, typename boost::enable_if_c<
  420. boost::conjunction<
  421. detail::path_traits::is_path_source_iterator< InputIterator >,
  422. boost::negation< detail::path_traits::is_native_char_ptr< InputIterator > >
  423. >::value
  424. >::type* = NULL)
  425. #endif
  426. {
  427. if (begin != end)
  428. {
  429. typedef std::basic_string< typename std::iterator_traits< InputIterator >::value_type > source_t;
  430. source_t source(begin, end);
  431. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  432. assign(static_cast< source_t&& >(source), cvt);
  433. #else
  434. assign(source, cvt);
  435. #endif
  436. }
  437. }
  438. #if !defined(BOOST_NO_CXX11_NULLPTR)
  439. BOOST_DELETED_FUNCTION(path(std::nullptr_t))
  440. BOOST_DELETED_FUNCTION(path& operator= (std::nullptr_t))
  441. #endif
  442. public:
  443. // ----- assignments -----
  444. // We need to explicitly define copy assignment as otherwise it will be implicitly defined as deleted because there is move assignment
  445. path& operator=(path const& p);
  446. template< typename Source >
  447. typename boost::enable_if_c<
  448. boost::disjunction<
  449. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >,
  450. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  451. >::value,
  452. path&
  453. >::type operator=(Source const& source)
  454. {
  455. return assign(source);
  456. }
  457. path& assign(path const& p)
  458. {
  459. m_pathname = p.m_pathname;
  460. return *this;
  461. }
  462. template< typename Source >
  463. typename boost::enable_if_c<
  464. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >::value,
  465. path&
  466. >::type assign(Source const& source)
  467. {
  468. detail::path_traits::dispatch(source, assign_op(*this));
  469. return *this;
  470. }
  471. template< typename Source >
  472. typename boost::enable_if_c<
  473. boost::conjunction<
  474. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >,
  475. boost::negation< detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type > >
  476. >::value,
  477. path&
  478. >::type assign(Source const& source)
  479. {
  480. detail::path_traits::dispatch_convertible(source, assign_op(*this));
  481. return *this;
  482. }
  483. path& assign(path const& p, codecvt_type const&)
  484. {
  485. m_pathname = p.m_pathname;
  486. return *this;
  487. }
  488. template< typename Source >
  489. typename boost::enable_if_c<
  490. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >::value,
  491. path&
  492. >::type assign(Source const& source, codecvt_type const& cvt)
  493. {
  494. detail::path_traits::dispatch(source, assign_op(*this), &cvt);
  495. return *this;
  496. }
  497. template< typename Source >
  498. typename boost::enable_if_c<
  499. boost::conjunction<
  500. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >,
  501. boost::negation< detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type > >
  502. >::value,
  503. path&
  504. >::type assign(Source const& source, codecvt_type const& cvt)
  505. {
  506. detail::path_traits::dispatch_convertible(source, assign_op(*this), &cvt);
  507. return *this;
  508. }
  509. path& assign(const value_type* begin, const value_type* end)
  510. {
  511. m_pathname.assign(begin, end);
  512. return *this;
  513. }
  514. template< typename InputIterator >
  515. typename boost::enable_if_c<
  516. boost::conjunction<
  517. detail::path_traits::is_path_source_iterator< InputIterator >,
  518. boost::negation< detail::path_traits::is_native_char_ptr< InputIterator > >
  519. >::value,
  520. path&
  521. >::type assign(InputIterator begin, InputIterator end)
  522. {
  523. m_pathname.clear();
  524. if (begin != end)
  525. {
  526. typedef std::basic_string< typename std::iterator_traits< InputIterator >::value_type > source_t;
  527. source_t source(begin, end);
  528. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  529. assign(static_cast< source_t&& >(source));
  530. #else
  531. assign(source);
  532. #endif
  533. }
  534. return *this;
  535. }
  536. path& assign(const value_type* begin, const value_type* end, codecvt_type const&)
  537. {
  538. m_pathname.assign(begin, end);
  539. return *this;
  540. }
  541. template< typename InputIterator >
  542. typename boost::enable_if_c<
  543. boost::conjunction<
  544. detail::path_traits::is_path_source_iterator< InputIterator >,
  545. boost::negation< detail::path_traits::is_native_char_ptr< InputIterator > >
  546. >::value,
  547. path&
  548. >::type assign(InputIterator begin, InputIterator end, codecvt_type const& cvt)
  549. {
  550. m_pathname.clear();
  551. if (begin != end)
  552. {
  553. typedef std::basic_string< typename std::iterator_traits< InputIterator >::value_type > source_t;
  554. source_t source(begin, end);
  555. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  556. assign(static_cast< source_t&& >(source), cvt);
  557. #else
  558. assign(source, cvt);
  559. #endif
  560. }
  561. return *this;
  562. }
  563. // ----- concatenation -----
  564. path& operator+=(path const& p);
  565. template< typename Source >
  566. typename boost::enable_if_c<
  567. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >::value,
  568. path&
  569. >::type operator+=(Source const& source)
  570. {
  571. return concat(source);
  572. }
  573. path& operator+=(value_type c)
  574. {
  575. m_pathname.push_back(c);
  576. return *this;
  577. }
  578. template< typename CharT >
  579. typename boost::enable_if_c<
  580. detail::path_traits::is_path_char_type< CharT >::value,
  581. path&
  582. >::type operator+=(CharT c)
  583. {
  584. CharT tmp[2];
  585. tmp[0] = c;
  586. tmp[1] = static_cast< CharT >(0);
  587. concat_op(*this)(tmp, tmp + 1);
  588. return *this;
  589. }
  590. path& concat(path const& p)
  591. {
  592. m_pathname.append(p.m_pathname);
  593. return *this;
  594. }
  595. template< typename Source >
  596. typename boost::enable_if_c<
  597. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >::value,
  598. path&
  599. >::type concat(Source const& source)
  600. {
  601. detail::path_traits::dispatch(source, concat_op(*this));
  602. return *this;
  603. }
  604. template< typename Source >
  605. typename boost::enable_if_c<
  606. boost::conjunction<
  607. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >,
  608. boost::negation< detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type > >
  609. >::value,
  610. path&
  611. >::type concat(Source const& source)
  612. {
  613. detail::path_traits::dispatch_convertible(source, concat_op(*this));
  614. return *this;
  615. }
  616. path& concat(path const& p, codecvt_type const&)
  617. {
  618. m_pathname.append(p.m_pathname);
  619. return *this;
  620. }
  621. template< typename Source >
  622. typename boost::enable_if_c<
  623. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >::value,
  624. path&
  625. >::type concat(Source const& source, codecvt_type const& cvt)
  626. {
  627. detail::path_traits::dispatch(source, concat_op(*this), &cvt);
  628. return *this;
  629. }
  630. template< typename Source >
  631. typename boost::enable_if_c<
  632. boost::conjunction<
  633. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >,
  634. boost::negation< detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type > >
  635. >::value,
  636. path&
  637. >::type concat(Source const& source, codecvt_type const& cvt)
  638. {
  639. detail::path_traits::dispatch_convertible(source, concat_op(*this), &cvt);
  640. return *this;
  641. }
  642. path& concat(const value_type* begin, const value_type* end)
  643. {
  644. m_pathname.append(begin, end);
  645. return *this;
  646. }
  647. template< typename InputIterator >
  648. typename boost::enable_if_c<
  649. boost::conjunction<
  650. detail::path_traits::is_path_source_iterator< InputIterator >,
  651. boost::negation< detail::path_traits::is_native_char_ptr< InputIterator > >
  652. >::value,
  653. path&
  654. >::type concat(InputIterator begin, InputIterator end)
  655. {
  656. if (begin != end)
  657. {
  658. std::basic_string< typename std::iterator_traits< InputIterator >::value_type > source(begin, end);
  659. detail::path_traits::dispatch(source, concat_op(*this));
  660. }
  661. return *this;
  662. }
  663. path& concat(const value_type* begin, const value_type* end, codecvt_type const&)
  664. {
  665. m_pathname.append(begin, end);
  666. return *this;
  667. }
  668. template< typename InputIterator >
  669. typename boost::enable_if_c<
  670. boost::conjunction<
  671. detail::path_traits::is_path_source_iterator< InputIterator >,
  672. boost::negation< detail::path_traits::is_native_char_ptr< InputIterator > >
  673. >::value,
  674. path&
  675. >::type concat(InputIterator begin, InputIterator end, codecvt_type const& cvt)
  676. {
  677. if (begin != end)
  678. {
  679. std::basic_string< typename std::iterator_traits< InputIterator >::value_type > source(begin, end);
  680. detail::path_traits::dispatch(source, concat_op(*this), &cvt);
  681. }
  682. return *this;
  683. }
  684. // ----- appends -----
  685. // if a separator is added, it is the preferred separator for the platform;
  686. // slash for POSIX, backslash for Windows
  687. path& operator/=(path const& p);
  688. template< typename Source >
  689. BOOST_FORCEINLINE typename boost::enable_if_c<
  690. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >::value,
  691. path&
  692. >::type operator/=(Source const& source)
  693. {
  694. return append(source);
  695. }
  696. path& append(path const& p);
  697. template< typename Source >
  698. BOOST_FORCEINLINE typename boost::enable_if_c<
  699. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >::value,
  700. path&
  701. >::type append(Source const& source)
  702. {
  703. detail::path_traits::dispatch(source, append_op(*this));
  704. return *this;
  705. }
  706. template< typename Source >
  707. BOOST_FORCEINLINE typename boost::enable_if_c<
  708. boost::conjunction<
  709. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >,
  710. boost::negation< detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type > >
  711. >::value,
  712. path&
  713. >::type append(Source const& source)
  714. {
  715. detail::path_traits::dispatch_convertible(source, append_op(*this));
  716. return *this;
  717. }
  718. path& append(path const& p, codecvt_type const&);
  719. template< typename Source >
  720. BOOST_FORCEINLINE typename boost::enable_if_c<
  721. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >::value,
  722. path&
  723. >::type append(Source const& source, codecvt_type const& cvt)
  724. {
  725. detail::path_traits::dispatch(source, append_op(*this), &cvt);
  726. return *this;
  727. }
  728. template< typename Source >
  729. BOOST_FORCEINLINE typename boost::enable_if_c<
  730. boost::conjunction<
  731. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >,
  732. boost::negation< detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type > >
  733. >::value,
  734. path&
  735. >::type append(Source const& source, codecvt_type const& cvt)
  736. {
  737. detail::path_traits::dispatch_convertible(source, append_op(*this), &cvt);
  738. return *this;
  739. }
  740. path& append(const value_type* begin, const value_type* end);
  741. template< typename InputIterator >
  742. BOOST_FORCEINLINE typename boost::enable_if_c<
  743. boost::conjunction<
  744. detail::path_traits::is_path_source_iterator< InputIterator >,
  745. boost::negation< detail::path_traits::is_native_char_ptr< InputIterator > >
  746. >::value,
  747. path&
  748. >::type append(InputIterator begin, InputIterator end)
  749. {
  750. std::basic_string< typename std::iterator_traits< InputIterator >::value_type > source(begin, end);
  751. detail::path_traits::dispatch(source, append_op(*this));
  752. return *this;
  753. }
  754. path& append(const value_type* begin, const value_type* end, codecvt_type const&);
  755. template< typename InputIterator >
  756. BOOST_FORCEINLINE typename boost::enable_if_c<
  757. boost::conjunction<
  758. detail::path_traits::is_path_source_iterator< InputIterator >,
  759. boost::negation< detail::path_traits::is_native_char_ptr< InputIterator > >
  760. >::value,
  761. path&
  762. >::type append(InputIterator begin, InputIterator end, const codecvt_type& cvt)
  763. {
  764. std::basic_string< typename std::iterator_traits< InputIterator >::value_type > source(begin, end);
  765. detail::path_traits::dispatch(source, append_op(*this), &cvt);
  766. return *this;
  767. }
  768. // ----- modifiers -----
  769. void clear() BOOST_NOEXCEPT { m_pathname.clear(); }
  770. #ifdef BOOST_POSIX_API
  771. path& make_preferred()
  772. {
  773. // No effect on POSIX
  774. return *this;
  775. }
  776. #else // BOOST_WINDOWS_API
  777. BOOST_FILESYSTEM_DECL path& make_preferred(); // change slashes to backslashes
  778. #endif
  779. path& remove_filename();
  780. BOOST_FILESYSTEM_DECL path& remove_filename_and_trailing_separators();
  781. BOOST_FILESYSTEM_DECL path& remove_trailing_separator();
  782. BOOST_FILESYSTEM_DECL path& replace_filename(path const& replacement);
  783. path& replace_extension(path const& new_extension = path());
  784. void swap(path& rhs) BOOST_NOEXCEPT { m_pathname.swap(rhs.m_pathname); }
  785. // ----- observers -----
  786. // For operating systems that format file paths differently than directory
  787. // paths, return values from observers are formatted as file names unless there
  788. // is a trailing separator, in which case returns are formatted as directory
  789. // paths. POSIX and Windows make no such distinction.
  790. // Implementations are permitted to return const values or const references.
  791. // The string or path returned by an observer are specified as being formatted
  792. // as "native" or "generic".
  793. //
  794. // For POSIX, these are all the same format; slashes and backslashes are as input and
  795. // are not modified.
  796. //
  797. // For Windows, native: as input; slashes and backslashes are not modified;
  798. // this is the format of the internally stored string.
  799. // generic: backslashes are converted to slashes
  800. // ----- native format observers -----
  801. string_type const& native() const BOOST_NOEXCEPT { return m_pathname; }
  802. const value_type* c_str() const BOOST_NOEXCEPT { return m_pathname.c_str(); }
  803. string_type::size_type size() const BOOST_NOEXCEPT { return m_pathname.size(); }
  804. template< typename String >
  805. String string() const;
  806. template< typename String >
  807. String string(codecvt_type const& cvt) const;
  808. #ifdef BOOST_WINDOWS_API
  809. std::string string() const
  810. {
  811. std::string tmp;
  812. if (!m_pathname.empty())
  813. detail::path_traits::convert(m_pathname.data(), m_pathname.data() + m_pathname.size(), tmp);
  814. return tmp;
  815. }
  816. std::string string(codecvt_type const& cvt) const
  817. {
  818. std::string tmp;
  819. if (!m_pathname.empty())
  820. detail::path_traits::convert(m_pathname.data(), m_pathname.data() + m_pathname.size(), tmp, &cvt);
  821. return tmp;
  822. }
  823. // string_type is std::wstring, so there is no conversion
  824. std::wstring const& wstring() const { return m_pathname; }
  825. std::wstring const& wstring(codecvt_type const&) const { return m_pathname; }
  826. #else // BOOST_POSIX_API
  827. // string_type is std::string, so there is no conversion
  828. std::string const& string() const { return m_pathname; }
  829. std::string const& string(codecvt_type const&) const { return m_pathname; }
  830. std::wstring wstring() const
  831. {
  832. std::wstring tmp;
  833. if (!m_pathname.empty())
  834. detail::path_traits::convert(m_pathname.data(), m_pathname.data() + m_pathname.size(), tmp);
  835. return tmp;
  836. }
  837. std::wstring wstring(codecvt_type const& cvt) const
  838. {
  839. std::wstring tmp;
  840. if (!m_pathname.empty())
  841. detail::path_traits::convert(m_pathname.data(), m_pathname.data() + m_pathname.size(), tmp, &cvt);
  842. return tmp;
  843. }
  844. #endif
  845. // ----- generic format observers -----
  846. // Experimental generic function returning generic formatted path (i.e. separators
  847. // are forward slashes). Motivation: simpler than a family of generic_*string
  848. // functions.
  849. #ifdef BOOST_WINDOWS_API
  850. BOOST_FILESYSTEM_DECL path generic_path() const;
  851. #else
  852. path generic_path() const;
  853. #endif
  854. template< typename String >
  855. String generic_string() const;
  856. template< typename String >
  857. String generic_string(codecvt_type const& cvt) const;
  858. #ifdef BOOST_WINDOWS_API
  859. std::string generic_string() const { return generic_path().string(); }
  860. std::string generic_string(codecvt_type const& cvt) const { return generic_path().string(cvt); }
  861. std::wstring generic_wstring() const { return generic_path().wstring(); }
  862. std::wstring generic_wstring(codecvt_type const&) const { return generic_wstring(); }
  863. #else // BOOST_POSIX_API
  864. // On POSIX-like systems, the generic format is the same as the native format
  865. std::string const& generic_string() const { return m_pathname; }
  866. std::string const& generic_string(codecvt_type const&) const { return m_pathname; }
  867. std::wstring generic_wstring() const { return this->wstring(); }
  868. std::wstring generic_wstring(codecvt_type const& cvt) const { return this->wstring(cvt); }
  869. #endif
  870. // ----- compare -----
  871. int compare(path const& p) const; // generic, lexicographical
  872. template< typename Source >
  873. BOOST_FORCEINLINE typename boost::enable_if_c<
  874. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >::value,
  875. int
  876. >::type compare(Source const& source) const
  877. {
  878. return detail::path_traits::dispatch(source, compare_op(*this));
  879. }
  880. template< typename Source >
  881. BOOST_FORCEINLINE typename boost::enable_if_c<
  882. boost::conjunction<
  883. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >,
  884. boost::negation< detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type > >
  885. >::value,
  886. int
  887. >::type compare(Source const& source) const
  888. {
  889. return detail::path_traits::dispatch_convertible(source, compare_op(*this));
  890. }
  891. template< typename Source >
  892. BOOST_FORCEINLINE typename boost::enable_if_c<
  893. detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type >::value,
  894. int
  895. >::type compare(Source const& source, codecvt_type const& cvt) const
  896. {
  897. return detail::path_traits::dispatch(source, compare_op(*this), &cvt);
  898. }
  899. template< typename Source >
  900. BOOST_FORCEINLINE typename boost::enable_if_c<
  901. boost::conjunction<
  902. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >,
  903. boost::negation< detail::path_traits::is_path_source< typename boost::remove_cv< Source >::type > >
  904. >::value,
  905. int
  906. >::type compare(Source const& source, codecvt_type const& cvt) const
  907. {
  908. return detail::path_traits::dispatch_convertible(source, compare_op(*this), &cvt);
  909. }
  910. // ----- decomposition -----
  911. path root_path() const { return path(m_pathname.c_str(), m_pathname.c_str() + detail::path_algorithms::find_root_path_size(*this)); }
  912. // returns 0 or 1 element path even on POSIX, root_name() is non-empty() for network paths
  913. path root_name() const { return path(m_pathname.c_str(), m_pathname.c_str() + detail::path_algorithms::find_root_name_size(*this)); }
  914. // returns 0 or 1 element path
  915. path root_directory() const
  916. {
  917. detail::path_algorithms::substring root_dir = detail::path_algorithms::find_root_directory(*this);
  918. const value_type* p = m_pathname.c_str() + root_dir.pos;
  919. return path(p, p + root_dir.size);
  920. }
  921. path relative_path() const
  922. {
  923. detail::path_algorithms::substring rel_path = detail::path_algorithms::find_relative_path(*this);
  924. const value_type* p = m_pathname.c_str() + rel_path.pos;
  925. return path(p, p + rel_path.size);
  926. }
  927. path parent_path() const { return path(m_pathname.c_str(), m_pathname.c_str() + detail::path_algorithms::find_parent_path_size(*this)); }
  928. path filename() const; // returns 0 or 1 element path
  929. path stem() const; // returns 0 or 1 element path
  930. path extension() const; // returns 0 or 1 element path
  931. // ----- query -----
  932. bool empty() const BOOST_NOEXCEPT { return m_pathname.empty(); }
  933. bool filename_is_dot() const;
  934. bool filename_is_dot_dot() const;
  935. bool has_root_path() const { return detail::path_algorithms::find_root_path_size(*this) > 0; }
  936. bool has_root_name() const { return detail::path_algorithms::find_root_name_size(*this) > 0; }
  937. bool has_root_directory() const { return detail::path_algorithms::find_root_directory(*this).size > 0; }
  938. bool has_relative_path() const { return detail::path_algorithms::find_relative_path(*this).size > 0; }
  939. bool has_parent_path() const { return detail::path_algorithms::find_parent_path_size(*this) > 0; }
  940. bool has_filename() const;
  941. bool has_stem() const { return !stem().empty(); }
  942. bool has_extension() const { return !extension().empty(); }
  943. bool is_relative() const { return !is_absolute(); }
  944. bool is_absolute() const
  945. {
  946. #if defined(BOOST_WINDOWS_API)
  947. return has_root_name() && has_root_directory();
  948. #else
  949. return has_root_directory();
  950. #endif
  951. }
  952. // ----- lexical operations -----
  953. path lexically_normal() const;
  954. BOOST_FILESYSTEM_DECL path lexically_relative(path const& base) const;
  955. path lexically_proximate(path const& base) const;
  956. // ----- iterators -----
  957. BOOST_FILESYSTEM_DECL iterator begin() const;
  958. BOOST_FILESYSTEM_DECL iterator end() const;
  959. reverse_iterator rbegin() const;
  960. reverse_iterator rend() const;
  961. // ----- static member functions -----
  962. static BOOST_FILESYSTEM_DECL std::locale imbue(std::locale const& loc);
  963. static BOOST_FILESYSTEM_DECL codecvt_type const& codecvt();
  964. // ----- deprecated functions -----
  965. #if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
  966. // recently deprecated functions supplied by default
  967. path& normalize();
  968. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::remove_filename() instead")
  969. path& remove_leaf() { return remove_filename(); }
  970. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::filename() instead")
  971. path leaf() const { return filename(); }
  972. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::parent_path() instead")
  973. path branch_path() const { return parent_path(); }
  974. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::generic_path() instead")
  975. path generic() const { return generic_path(); }
  976. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use !path::empty() instead")
  977. bool has_leaf() const { return !m_pathname.empty(); }
  978. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::has_parent_path() instead")
  979. bool has_branch_path() const { return has_parent_path(); }
  980. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::is_absolute() instead")
  981. bool is_complete() const { return is_absolute(); }
  982. #endif
  983. #if defined(BOOST_FILESYSTEM_DEPRECATED)
  984. // deprecated functions with enough signature or semantic changes that they are
  985. // not supplied by default
  986. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::string() instead")
  987. std::string file_string() const { return string(); }
  988. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::string() instead")
  989. std::string directory_string() const { return string(); }
  990. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::string() instead")
  991. std::string native_file_string() const { return string(); }
  992. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::string() instead")
  993. std::string native_directory_string() const { return string(); }
  994. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::native() instead")
  995. string_type external_file_string() const { return native(); }
  996. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::native() instead")
  997. string_type external_directory_string() const { return native(); }
  998. #endif
  999. //--------------------------------------------------------------------------------------//
  1000. // class path private members //
  1001. //--------------------------------------------------------------------------------------//
  1002. private:
  1003. /*
  1004. * m_pathname has the type, encoding, and format required by the native
  1005. * operating system. Thus for POSIX and Windows there is no conversion for
  1006. * passing m_pathname.c_str() to the O/S API or when obtaining a path from the
  1007. * O/S API. POSIX encoding is unspecified other than for dot and slash
  1008. * characters; POSIX just treats paths as a sequence of bytes. Windows
  1009. * encoding is UCS-2 or UTF-16 depending on the version.
  1010. */
  1011. string_type m_pathname; // Windows: as input; backslashes NOT converted to slashes,
  1012. // slashes NOT converted to backslashes
  1013. };
  1014. namespace detail {
  1015. BOOST_FILESYSTEM_DECL path const& dot_path();
  1016. BOOST_FILESYSTEM_DECL path const& dot_dot_path();
  1017. } // namespace detail
  1018. #ifndef BOOST_FILESYSTEM_NO_DEPRECATED
  1019. typedef path wpath;
  1020. #endif
  1021. namespace path_detail {
  1022. //------------------------------------------------------------------------------------//
  1023. // class path::iterator //
  1024. //------------------------------------------------------------------------------------//
  1025. class path_iterator :
  1026. public boost::iterator_facade<
  1027. path_iterator,
  1028. const path,
  1029. boost::bidirectional_traversal_tag
  1030. >
  1031. {
  1032. private:
  1033. friend class boost::iterator_core_access;
  1034. friend class boost::filesystem::path;
  1035. friend class path_reverse_iterator;
  1036. friend struct boost::filesystem::detail::path_algorithms;
  1037. path const& dereference() const { return m_element; }
  1038. bool equal(path_iterator const& rhs) const BOOST_NOEXCEPT
  1039. {
  1040. return m_path_ptr == rhs.m_path_ptr && m_pos == rhs.m_pos;
  1041. }
  1042. void increment();
  1043. void decrement();
  1044. private:
  1045. // current element
  1046. path m_element;
  1047. // path being iterated over
  1048. const path* m_path_ptr;
  1049. // position of m_element in m_path_ptr->m_pathname.
  1050. // if m_element is implicit dot, m_pos is the
  1051. // position of the last separator in the path.
  1052. // end() iterator is indicated by
  1053. // m_pos == m_path_ptr->m_pathname.size()
  1054. path::string_type::size_type m_pos;
  1055. };
  1056. //------------------------------------------------------------------------------------//
  1057. // class path::reverse_iterator //
  1058. //------------------------------------------------------------------------------------//
  1059. class path_reverse_iterator :
  1060. public boost::iterator_facade<
  1061. path_reverse_iterator,
  1062. const path,
  1063. boost::bidirectional_traversal_tag
  1064. >
  1065. {
  1066. public:
  1067. explicit path_reverse_iterator(path_iterator itr) :
  1068. m_itr(itr)
  1069. {
  1070. if (itr != itr.m_path_ptr->begin())
  1071. m_element = *--itr;
  1072. }
  1073. private:
  1074. friend class boost::iterator_core_access;
  1075. friend class boost::filesystem::path;
  1076. path const& dereference() const { return m_element; }
  1077. bool equal(path_reverse_iterator const& rhs) const BOOST_NOEXCEPT { return m_itr == rhs.m_itr; }
  1078. void increment()
  1079. {
  1080. --m_itr;
  1081. if (m_itr != m_itr.m_path_ptr->begin())
  1082. {
  1083. path_iterator tmp = m_itr;
  1084. m_element = *--tmp;
  1085. }
  1086. }
  1087. void decrement()
  1088. {
  1089. m_element = *m_itr;
  1090. ++m_itr;
  1091. }
  1092. private:
  1093. path_iterator m_itr;
  1094. path m_element;
  1095. };
  1096. // std::lexicographical_compare would infinitely recurse because path iterators
  1097. // yield paths, so provide a path aware version
  1098. bool lexicographical_compare(path_iterator first1, path_iterator const& last1, path_iterator first2, path_iterator const& last2);
  1099. } // namespace path_detail
  1100. using path_detail::lexicographical_compare;
  1101. //------------------------------------------------------------------------------------//
  1102. // //
  1103. // non-member functions //
  1104. // //
  1105. //------------------------------------------------------------------------------------//
  1106. BOOST_FORCEINLINE bool operator==(path const& lhs, path const& rhs)
  1107. {
  1108. return lhs.compare(rhs) == 0;
  1109. }
  1110. template< typename Path, typename Source >
  1111. BOOST_FORCEINLINE typename boost::enable_if_c<
  1112. boost::conjunction<
  1113. boost::is_same< Path, path >,
  1114. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1115. >::value,
  1116. bool
  1117. >::type operator==(Path const& lhs, Source const& rhs)
  1118. {
  1119. return lhs.compare(rhs) == 0;
  1120. }
  1121. template< typename Source, typename Path >
  1122. BOOST_FORCEINLINE typename boost::enable_if_c<
  1123. boost::conjunction<
  1124. boost::is_same< Path, path >,
  1125. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1126. >::value,
  1127. bool
  1128. >::type operator==(Source const& lhs, Path const& rhs)
  1129. {
  1130. return rhs.compare(lhs) == 0;
  1131. }
  1132. BOOST_FORCEINLINE bool operator!=(path const& lhs, path const& rhs)
  1133. {
  1134. return lhs.compare(rhs) != 0;
  1135. }
  1136. template< typename Path, typename Source >
  1137. BOOST_FORCEINLINE typename boost::enable_if_c<
  1138. boost::conjunction<
  1139. boost::is_same< Path, path >,
  1140. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1141. >::value,
  1142. bool
  1143. >::type operator!=(Path const& lhs, Source const& rhs)
  1144. {
  1145. return lhs.compare(rhs) != 0;
  1146. }
  1147. template< typename Source, typename Path >
  1148. BOOST_FORCEINLINE typename boost::enable_if_c<
  1149. boost::conjunction<
  1150. boost::is_same< Path, path >,
  1151. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1152. >::value,
  1153. bool
  1154. >::type operator!=(Source const& lhs, Path const& rhs)
  1155. {
  1156. return rhs.compare(lhs) != 0;
  1157. }
  1158. BOOST_FORCEINLINE bool operator<(path const& lhs, path const& rhs)
  1159. {
  1160. return lhs.compare(rhs) < 0;
  1161. }
  1162. template< typename Path, typename Source >
  1163. BOOST_FORCEINLINE typename boost::enable_if_c<
  1164. boost::conjunction<
  1165. boost::is_same< Path, path >,
  1166. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1167. >::value,
  1168. bool
  1169. >::type operator<(Path const& lhs, Source const& rhs)
  1170. {
  1171. return lhs.compare(rhs) < 0;
  1172. }
  1173. template< typename Source, typename Path >
  1174. BOOST_FORCEINLINE typename boost::enable_if_c<
  1175. boost::conjunction<
  1176. boost::is_same< Path, path >,
  1177. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1178. >::value,
  1179. bool
  1180. >::type operator<(Source const& lhs, Path const& rhs)
  1181. {
  1182. return rhs.compare(lhs) > 0;
  1183. }
  1184. BOOST_FORCEINLINE bool operator<=(path const& lhs, path const& rhs)
  1185. {
  1186. return lhs.compare(rhs) <= 0;
  1187. }
  1188. template< typename Path, typename Source >
  1189. BOOST_FORCEINLINE typename boost::enable_if_c<
  1190. boost::conjunction<
  1191. boost::is_same< Path, path >,
  1192. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1193. >::value,
  1194. bool
  1195. >::type operator<=(Path const& lhs, Source const& rhs)
  1196. {
  1197. return lhs.compare(rhs) <= 0;
  1198. }
  1199. template< typename Source, typename Path >
  1200. BOOST_FORCEINLINE typename boost::enable_if_c<
  1201. boost::conjunction<
  1202. boost::is_same< Path, path >,
  1203. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1204. >::value,
  1205. bool
  1206. >::type operator<=(Source const& lhs, Path const& rhs)
  1207. {
  1208. return rhs.compare(lhs) >= 0;
  1209. }
  1210. BOOST_FORCEINLINE bool operator>(path const& lhs, path const& rhs)
  1211. {
  1212. return lhs.compare(rhs) > 0;
  1213. }
  1214. template< typename Path, typename Source >
  1215. BOOST_FORCEINLINE typename boost::enable_if_c<
  1216. boost::conjunction<
  1217. boost::is_same< Path, path >,
  1218. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1219. >::value,
  1220. bool
  1221. >::type operator>(Path const& lhs, Source const& rhs)
  1222. {
  1223. return lhs.compare(rhs) > 0;
  1224. }
  1225. template< typename Source, typename Path >
  1226. BOOST_FORCEINLINE typename boost::enable_if_c<
  1227. boost::conjunction<
  1228. boost::is_same< Path, path >,
  1229. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1230. >::value,
  1231. bool
  1232. >::type operator>(Source const& lhs, Path const& rhs)
  1233. {
  1234. return rhs.compare(lhs) < 0;
  1235. }
  1236. BOOST_FORCEINLINE bool operator>=(path const& lhs, path const& rhs)
  1237. {
  1238. return lhs.compare(rhs) >= 0;
  1239. }
  1240. template< typename Path, typename Source >
  1241. BOOST_FORCEINLINE typename boost::enable_if_c<
  1242. boost::conjunction<
  1243. boost::is_same< Path, path >,
  1244. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1245. >::value,
  1246. bool
  1247. >::type operator>=(Path const& lhs, Source const& rhs)
  1248. {
  1249. return lhs.compare(rhs) >= 0;
  1250. }
  1251. template< typename Source, typename Path >
  1252. BOOST_FORCEINLINE typename boost::enable_if_c<
  1253. boost::conjunction<
  1254. boost::is_same< Path, path >,
  1255. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >
  1256. >::value,
  1257. bool
  1258. >::type operator>=(Source const& lhs, Path const& rhs)
  1259. {
  1260. return rhs.compare(lhs) <= 0;
  1261. }
  1262. // Note: Declared as a template to delay binding to Boost.ContainerHash functions and make the dependency optional
  1263. template< typename Path >
  1264. inline typename boost::enable_if_c<
  1265. boost::is_same< Path, path >::value,
  1266. std::size_t
  1267. >::type hash_value(Path const& p) BOOST_NOEXCEPT
  1268. {
  1269. #ifdef BOOST_WINDOWS_API
  1270. std::size_t seed = 0u;
  1271. for (typename Path::value_type const* it = p.c_str(); *it; ++it)
  1272. hash_combine(seed, *it == L'/' ? L'\\' : *it);
  1273. return seed;
  1274. #else // BOOST_POSIX_API
  1275. return hash_range(p.native().begin(), p.native().end());
  1276. #endif
  1277. }
  1278. inline void swap(path& lhs, path& rhs) BOOST_NOEXCEPT
  1279. {
  1280. lhs.swap(rhs);
  1281. }
  1282. BOOST_FORCEINLINE path operator/(path lhs, path const& rhs)
  1283. {
  1284. lhs.append(rhs);
  1285. return lhs;
  1286. }
  1287. template< typename Source >
  1288. BOOST_FORCEINLINE typename boost::enable_if_c<
  1289. detail::path_traits::is_convertible_to_path_source< typename boost::remove_cv< Source >::type >::value,
  1290. path
  1291. >::type operator/(path lhs, Source const& rhs)
  1292. {
  1293. lhs.append(rhs);
  1294. return lhs;
  1295. }
  1296. // inserters and extractors
  1297. // use boost::io::quoted() to handle spaces in paths
  1298. // use '&' as escape character to ease use for Windows paths
  1299. template< typename Char, typename Traits >
  1300. inline std::basic_ostream< Char, Traits >&
  1301. operator<<(std::basic_ostream< Char, Traits >& os, path const& p)
  1302. {
  1303. return os << boost::io::quoted(p.template string< std::basic_string< Char > >(), static_cast< Char >('&'));
  1304. }
  1305. template< typename Char, typename Traits >
  1306. inline std::basic_istream< Char, Traits >&
  1307. operator>>(std::basic_istream< Char, Traits >& is, path& p)
  1308. {
  1309. std::basic_string< Char > str;
  1310. is >> boost::io::quoted(str, static_cast< Char >('&'));
  1311. p = str;
  1312. return is;
  1313. }
  1314. // name_checks
  1315. // These functions are holdovers from version 1. It isn't clear they have much
  1316. // usefulness, or how to generalize them for later versions.
  1317. BOOST_FILESYSTEM_DECL bool portable_posix_name(std::string const& name);
  1318. BOOST_FILESYSTEM_DECL bool windows_name(std::string const& name);
  1319. BOOST_FILESYSTEM_DECL bool portable_name(std::string const& name);
  1320. BOOST_FILESYSTEM_DECL bool portable_directory_name(std::string const& name);
  1321. BOOST_FILESYSTEM_DECL bool portable_file_name(std::string const& name);
  1322. BOOST_FILESYSTEM_DECL bool native(std::string const& name);
  1323. namespace detail {
  1324. // For POSIX, is_directory_separator() and is_element_separator() are identical since
  1325. // a forward slash is the only valid directory separator and also the only valid
  1326. // element separator. For Windows, forward slash and back slash are the possible
  1327. // directory separators, but colon (example: "c:foo") is also an element separator.
  1328. inline bool is_directory_separator(path::value_type c) BOOST_NOEXCEPT
  1329. {
  1330. return c == path::separator
  1331. #ifdef BOOST_WINDOWS_API
  1332. || c == path::preferred_separator
  1333. #endif
  1334. ;
  1335. }
  1336. inline bool is_element_separator(path::value_type c) BOOST_NOEXCEPT
  1337. {
  1338. return c == path::separator
  1339. #ifdef BOOST_WINDOWS_API
  1340. || c == path::preferred_separator || c == L':'
  1341. #endif
  1342. ;
  1343. }
  1344. } // namespace detail
  1345. //------------------------------------------------------------------------------------//
  1346. // class path miscellaneous function implementations //
  1347. //------------------------------------------------------------------------------------//
  1348. namespace detail {
  1349. inline bool path_algorithms::has_filename_v3(path const& p)
  1350. {
  1351. return !p.m_pathname.empty();
  1352. }
  1353. inline bool path_algorithms::has_filename_v4(path const& p)
  1354. {
  1355. return path_algorithms::find_filename_v4_size(p) > 0;
  1356. }
  1357. inline path path_algorithms::filename_v4(path const& p)
  1358. {
  1359. string_type::size_type filename_size = path_algorithms::find_filename_v4_size(p);
  1360. string_type::size_type pos = p.m_pathname.size() - filename_size;
  1361. const value_type* ptr = p.m_pathname.c_str() + pos;
  1362. return path(ptr, ptr + filename_size);
  1363. }
  1364. inline path path_algorithms::extension_v4(path const& p)
  1365. {
  1366. string_type::size_type extension_size = path_algorithms::find_extension_v4_size(p);
  1367. string_type::size_type pos = p.m_pathname.size() - extension_size;
  1368. const value_type* ptr = p.m_pathname.c_str() + pos;
  1369. return path(ptr, ptr + extension_size);
  1370. }
  1371. inline void path_algorithms::append_v4(path& left, path const& right)
  1372. {
  1373. path_algorithms::append_v4(left, right.m_pathname.c_str(), right.m_pathname.c_str() + right.m_pathname.size());
  1374. }
  1375. } // namespace detail
  1376. // Note: Because of the range constructor in C++23 std::string_view that involves a check for contiguous_range concept,
  1377. // any non-template function call that requires a check whether the source argument (which may be fs::path)
  1378. // is convertible to std::string_view must be made after fs::path::iterator is defined. This includes overload
  1379. // resolution and SFINAE checks. Otherwise, the concept check result formally changes between fs::path::iterator
  1380. // is not defined and defined, which causes compilation errors with gcc 11 and later.
  1381. // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106808
  1382. BOOST_FORCEINLINE path::compare_op::result_type path::compare_op::operator() (const value_type* source, const value_type* source_end, const codecvt_type*) const
  1383. {
  1384. path src;
  1385. src.m_pathname.assign(source, source_end);
  1386. return m_self.compare(src);
  1387. }
  1388. template< typename OtherChar >
  1389. BOOST_FORCEINLINE path::compare_op::result_type path::compare_op::operator() (const OtherChar* source, const OtherChar* source_end, const codecvt_type* cvt) const
  1390. {
  1391. path src;
  1392. detail::path_traits::convert(source, source_end, src.m_pathname, cvt);
  1393. return m_self.compare(src);
  1394. }
  1395. inline path& path::operator=(path const& p)
  1396. {
  1397. return assign(p);
  1398. }
  1399. inline path& path::operator+=(path const& p)
  1400. {
  1401. return concat(p);
  1402. }
  1403. BOOST_FORCEINLINE path& path::operator/=(path const& p)
  1404. {
  1405. return append(p);
  1406. }
  1407. #if !defined(BOOST_WINDOWS_API)
  1408. inline path path::generic_path() const
  1409. {
  1410. return path(*this);
  1411. }
  1412. #endif
  1413. inline path path::lexically_proximate(path const& base) const
  1414. {
  1415. path tmp(lexically_relative(base));
  1416. return tmp.empty() ? *this : tmp;
  1417. }
  1418. inline path::reverse_iterator path::rbegin() const
  1419. {
  1420. return reverse_iterator(end());
  1421. }
  1422. inline path::reverse_iterator path::rend() const
  1423. {
  1424. return reverse_iterator(begin());
  1425. }
  1426. inline bool path::filename_is_dot() const
  1427. {
  1428. // implicit dot is tricky, so actually call filename(); see path::filename() example
  1429. // in reference.html
  1430. path p(filename());
  1431. return p.size() == 1 && *p.c_str() == dot;
  1432. }
  1433. inline bool path::filename_is_dot_dot() const
  1434. {
  1435. return size() >= 2 && m_pathname[size() - 1] == dot && m_pathname[size() - 2] == dot && (m_pathname.size() == 2 || detail::is_element_separator(m_pathname[size() - 3]));
  1436. // use detail::is_element_separator() rather than detail::is_directory_separator
  1437. // to deal with "c:.." edge case on Windows when ':' acts as a separator
  1438. }
  1439. #if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
  1440. BOOST_FILESYSTEM_DETAIL_DEPRECATED("Use path::lexically_normal() instead")
  1441. BOOST_FORCEINLINE path& path::normalize()
  1442. {
  1443. path tmp(lexically_normal());
  1444. m_pathname.swap(tmp.m_pathname);
  1445. return *this;
  1446. }
  1447. #endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
  1448. // The following functions are defined differently, depending on Boost.Filesystem version in use.
  1449. // To avoid ODR violation, these functions are not defined when the library itself is built.
  1450. // This makes sure they are not compiled when the library is built, and the only version there is
  1451. // is the one in user's code. Users are supposed to consistently use the same Boost.Filesystem version
  1452. // in all their translation units.
  1453. #if !defined(BOOST_FILESYSTEM_SOURCE)
  1454. BOOST_FORCEINLINE path& path::append(path const& p)
  1455. {
  1456. BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::append)(*this, p.m_pathname.data(), p.m_pathname.data() + p.m_pathname.size());
  1457. return *this;
  1458. }
  1459. BOOST_FORCEINLINE path& path::append(path const& p, codecvt_type const&)
  1460. {
  1461. BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::append)(*this, p.m_pathname.data(), p.m_pathname.data() + p.m_pathname.size());
  1462. return *this;
  1463. }
  1464. BOOST_FORCEINLINE path& path::append(const value_type* begin, const value_type* end)
  1465. {
  1466. BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::append)(*this, begin, end);
  1467. return *this;
  1468. }
  1469. BOOST_FORCEINLINE path& path::append(const value_type* begin, const value_type* end, codecvt_type const&)
  1470. {
  1471. BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::append)(*this, begin, end);
  1472. return *this;
  1473. }
  1474. BOOST_FORCEINLINE path& path::remove_filename()
  1475. {
  1476. BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::remove_filename)(*this);
  1477. return *this;
  1478. }
  1479. BOOST_FORCEINLINE path& path::replace_extension(path const& new_extension)
  1480. {
  1481. BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::replace_extension)(*this, new_extension);
  1482. return *this;
  1483. }
  1484. BOOST_FORCEINLINE int path::compare(path const& p) const
  1485. {
  1486. return BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::compare)(*this, p);
  1487. }
  1488. BOOST_FORCEINLINE path path::filename() const
  1489. {
  1490. return BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::filename)(*this);
  1491. }
  1492. BOOST_FORCEINLINE path path::stem() const
  1493. {
  1494. return BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::stem)(*this);
  1495. }
  1496. BOOST_FORCEINLINE path path::extension() const
  1497. {
  1498. return BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::extension)(*this);
  1499. }
  1500. BOOST_FORCEINLINE bool path::has_filename() const
  1501. {
  1502. return BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::has_filename)(*this);
  1503. }
  1504. BOOST_FORCEINLINE path path::lexically_normal() const
  1505. {
  1506. return BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::lexically_normal)(*this);
  1507. }
  1508. namespace path_detail {
  1509. BOOST_FORCEINLINE void path_iterator::increment()
  1510. {
  1511. BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::increment)(*this);
  1512. }
  1513. BOOST_FORCEINLINE void path_iterator::decrement()
  1514. {
  1515. BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::decrement)(*this);
  1516. }
  1517. BOOST_FORCEINLINE bool lexicographical_compare(path_iterator first1, path_iterator const& last1, path_iterator first2, path_iterator const& last2)
  1518. {
  1519. return BOOST_FILESYSTEM_VERSIONED_SYM(detail::path_algorithms::lex_compare)(first1, last1, first2, last2) < 0;
  1520. }
  1521. } // namespace path_detail
  1522. #endif // !defined(BOOST_FILESYSTEM_SOURCE)
  1523. //--------------------------------------------------------------------------------------//
  1524. // class path member template specializations //
  1525. //--------------------------------------------------------------------------------------//
  1526. template< >
  1527. inline std::string path::string< std::string >() const
  1528. {
  1529. return string();
  1530. }
  1531. template< >
  1532. inline std::wstring path::string< std::wstring >() const
  1533. {
  1534. return wstring();
  1535. }
  1536. template< >
  1537. inline std::string path::string< std::string >(codecvt_type const& cvt) const
  1538. {
  1539. return string(cvt);
  1540. }
  1541. template< >
  1542. inline std::wstring path::string< std::wstring >(codecvt_type const& cvt) const
  1543. {
  1544. return wstring(cvt);
  1545. }
  1546. template< >
  1547. inline std::string path::generic_string< std::string >() const
  1548. {
  1549. return generic_string();
  1550. }
  1551. template< >
  1552. inline std::wstring path::generic_string< std::wstring >() const
  1553. {
  1554. return generic_wstring();
  1555. }
  1556. template< >
  1557. inline std::string path::generic_string< std::string >(codecvt_type const& cvt) const
  1558. {
  1559. return generic_string(cvt);
  1560. }
  1561. template< >
  1562. inline std::wstring path::generic_string< std::wstring >(codecvt_type const& cvt) const
  1563. {
  1564. return generic_wstring(cvt);
  1565. }
  1566. } // namespace filesystem
  1567. } // namespace boost
  1568. //----------------------------------------------------------------------------//
  1569. #include <boost/filesystem/detail/footer.hpp>
  1570. #endif // BOOST_FILESYSTEM_PATH_HPP