Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / filesystem / doc / reference.html
1 <html>
2 <!-- &copy; Copyright Beman Dawes, 2002, 2006, 2007, 2009, 2010, 2011 -->
3 <!-- Distributed under the Boost Software License, Version 1.0. -->
4 <!-- See http://www.boost.org/LICENSE_1_0.txt -->
5
6 <!-- generate-section-numbers=false -->
7
8 <head>
9 <meta http-equiv="Content-Language" content="en-us">
10 <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
11 <meta name="ProgId" content="FrontPage.Editor.Document">
12 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
13 <link href="styles.css" rel="stylesheet">
14 <title>Filesystem Reference</title>
15 </head>
16
17 <body>
18
19
20
21 <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
22   <tr>
23     <td width="277">
24 <p>
25 <a href="../../../index.htm">
26 <img src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle" width="300" height="86" border="0"></a></td>
27     <td align="middle">
28     <font size="7">Filesystem Library<br>
29     </font>
30     <font size="6">Version 3</font></td>
31   </tr>
32 </table>
33
34 <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
35  bordercolor="#111111" bgcolor="#D7EEFF" width="100%">
36   <tr>
37     <td><a href="index.htm">Home</a> &nbsp;&nbsp;
38     <a href="tutorial.html">Tutorial</a> &nbsp;&nbsp;
39     <a href="reference.html">Reference</a> &nbsp;&nbsp;
40     <a href="faq.htm">FAQ</a> &nbsp;&nbsp;
41     <a href="release_history.html">Releases</a> &nbsp;&nbsp;
42     <a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
43     <a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
44     <a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
45     <a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;
46     <a href="issue_reporting.html">Bug Reports </a>&nbsp;&nbsp;
47     </td>
48 </table>
49
50 <h1>Reference Documentation</h1>
51
52
53
54 <h2><a name="TOC">Table of Contents</a></h2>
55
56 <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
57   <tr>
58     <td width="33%" valign="top">
59     <p><a href="#Introduction">Introduction</a><br>
60     <a href="#Definitions">Definitions</a><br>
61     <a href="#Conformance">Conformance</a><br>
62     <a href="#Header-filesystem-synopsis">
63     Header <code>&lt;boost/filesystem.hpp&gt;</code> synopsis</a><br>
64     <a href="#Error-reporting">Error reporting</a><br>
65     <a href="#class-path">Class <code>path</code></a><br>
66 &nbsp;&nbsp;&nbsp; <a href="#path-Conversions"><code>path</code> conversions</a><br>
67 &nbsp;&nbsp;&nbsp; <a href="#path-Conversions-to-native-format"><code>path</code>
68     conversions to native format</a><br>
69 &nbsp;&nbsp;&nbsp; <a href="#path-Conversions-to-generic-format"><code>path</code>
70     conversions to generic format</a><br>
71 &nbsp;&nbsp;&nbsp; <a href="#path-Encoding-conversions"><code>path</code>
72     encoding conversions</a><br>
73 &nbsp;&nbsp;&nbsp; <a href="#path-Requirements"><code>path</code> requirements</a><br>
74     &nbsp;&nbsp;&nbsp; <a href="#path-constructors"><code>path</code> constructors</a><br>
75 &nbsp;&nbsp;&nbsp; <a href="#path-assignments"><code>path</code> assignments</a><br>
76     &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-appends"><code>path</code> appends</a><br>
77     &nbsp;&nbsp; &nbsp;<a href="#path-concatenation"><code>path</code> concatenation</a><br>
78 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-modifiers"><code>path</code> modifiers</a><br>
79 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-native-format-observers"><code>path</code> native
80     format observers</a><br>
81 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-generic-format-observers"><code>path</code> generic
82     format observers</a><br>
83 &nbsp;&nbsp;&nbsp; <a href="#path-compare"><code>path</code> compare</a><br>
84 &nbsp;&nbsp;&nbsp; <a href="#path-decomposition"><code>path</code> decomposition</a><br>
85 &nbsp;&nbsp;&nbsp; <a href="#path-query"><code>path</code> query</a><br>
86 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-iterators"><code>path</code> iterators</a><br>
87
88 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-deprecated-functions"><code>path</code> deprecated functions</a><br>
89 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-non-member-functions"><code>path</code> non-member functions</a><br>
90 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#path-inserter-extractor"><code>path</code> inserters and extractors</a><br>
91  &nbsp;<a href="#Class-filesystem_error">Class <code>filesystem_error</code></a><br>
92 &nbsp;&nbsp;&nbsp; <a href="#filesystem_error-members"><code>filesystem_error</code>
93     constructors</a><br>
94 &nbsp;&nbsp;&nbsp; <a href="#filesystem_error-path1"><code>filesystem_error</code> path1</a><br>
95 &nbsp;&nbsp;&nbsp; <a href="#filesystem_error-path2"><code>filesystem_error</code> path2</a><br>
96 &nbsp;&nbsp;&nbsp; <a href="#filesystem_error-what"><code>filesystem_error</code> what</a></td>
97     <td width="33%" valign="top">
98     <p>
99     <a href="#Enum-file_type">Enum <code>file_type</code></a><br>
100     <a href="#Enum-perms">Enum <code>perms</code></a><br>
101     <a href="#file_status">Class
102     <code>file_status</code></a><br>
103 &nbsp;&nbsp;&nbsp;
104     <a href="#file_status">
105     <code>file_status</code></a><a href="#file_status-constructors"> constructors</a><br>
106 &nbsp;&nbsp;&nbsp;&nbsp;<code><a href="#file_status-modifiers">file_status-modifiers</a></code><a href="#directory_entry-observers"> observers</a><br>
107 &nbsp;&nbsp;&nbsp;&nbsp;<code><a href="#file_status-observers">file_status-observers</a></code><a href="#directory_entry-modifiers"> modifiers</a><br>
108 <a href="#Class-directory_entry">Class <code>directory_entry</code></a><br>
109 &nbsp;&nbsp;&nbsp;
110 <a href="#directory_entry-constructors"><code>directory_entry</code> constructors</a><br>
111 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#directory_entry-observers"><code>directory_entry</code> observers</a><br>
112 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#directory_entry-modifiers"><code>directory_entry</code> modifiers</a><br>
113 <a href="#Class-directory_iterator">Class  <code>directory_iterator</code></a><br>
114 &nbsp;&nbsp;&nbsp; <a href="#directory_iterator-members"><code>directory_iterator</code>
115     members</a><br>
116 <a href="#Class-recursive_directory_iterator">Class <code>recursive_directory_iterator</code></a><br>
117     <a href="#Operational-functions">
118     Operational functions</a><br>
119     <code>&nbsp;&nbsp;&nbsp;&nbsp; <a href="#absolute">absolute</a><br>
120 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#canonical">canonical</a><br>
121 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#copy">copy</a><br>
122 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#copy_directory">copy_directory</a><br>
123 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#copy_file">copy_file</a><br>
124 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#copy_symlink">copy_symlink</a><br>
125 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#create_directories">create_directories</a><br>
126 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#create_directory">create_directory</a><br>
127 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#create_hard_link">create_hard_link</a><br>
128 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#create_symlink">create_symlink</a><br>
129 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#current_path">current_path</a><br>
130 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#exists">exists</a><br>
131 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#equivalent">equivalent</a><br>
132 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#file_size">file_size</a><br>
133 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#hard_link_count">hard_link_count</a><br>
134 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#initial_path">initial_path</a><br>
135 &nbsp;&nbsp;&nbsp;&nbsp;  i<a href="#is_directory">s_directory</a><br>
136 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_empty">is_empty</a></code></td>
137     <td width="34%" valign="top">
138     <p>
139     <code>&nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_other">is_other</a><br>
140 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_regular_file">is_regular_file</a><br>
141 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#is_symlink">is_symlink</a><br>
142 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#last_write_time">last_write_time</a><br>
143 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#permissions">permissions</a><br>
144 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#read_symlink">read_symlink</a><br>
145 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#op-relative">relative</a><br>
146 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#remove">remove</a><br>
147 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#remove_all">remove_all</a><br>
148 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#rename">rename</a><br>
149 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#resize_file">resize_file</a><br>
150 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#space">space</a><br>
151 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#status">status</a><br>
152 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#status_known">status_known</a><br>
153 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#symlink_status">symlink_status</a><br>
154 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#system_complete">system_complete</a><br>
155 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#temp_directory_path">temp_directory_path</a><br>
156 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#unique_path">unique_path</a><br>
157 &nbsp;&nbsp;&nbsp;&nbsp; <a href="#weakly_canonical">weakly_canonical</a><br></code>
158     <a href="#File-streams">File streams</a><br>
159 <a href="#path-decomposition-table">Path decomposition table</a><br>
160     <a href="#long-path-warning">Warning: Long paths on Windows and the
161     extended-length <b>\\?\ </b>prefix</a><br>
162 <a href="#Acknowledgements">Acknowledgements</a><br>
163 <a href="#References">References</a><br>
164 &nbsp;</td>
165   </tr>
166 </table>
167
168
169 <h2><a name="Introduction">Introduction</a></h2>
170
171 <p>This reference documentation describes components that C++ programs may use
172 to perform operations involving file systems, including paths, regular files,
173 and directories.</p>
174
175 <blockquote>
176 <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
177   bordercolor="#111111" bgcolor="#D7EEFF" width="90%">
178   <tr>
179     <td width="100%" align="center" colspan="2">
180     <p align="center"><b>C++11 Support</b><p align="left">This reference
181     documentation is written as if all compilers supported C++11. Where
182     possible, the implementation falls back to C++03 if a C++11 feature is not
183     available.</td>
184   </tr>
185   <tr>
186     <td width="35%" align="center">
187     <p>
188     <b>C++11 Feature</b></td>
189     <td width="65%" align="center">
190     <p>
191     <b>Action if not supported by compiler</b></td>
192   </tr>
193   <tr>
194     <td width="35%" align="left">
195     <p>
196     <code>noexcept</code></td>
197     <td width="65%" align="left">
198     <p>Keyword omitted.</td>
199   </tr>
200   <tr>
201     <td width="35%" align="left">
202     <p>
203     <code>constexpr</code></td>
204     <td width="65%" align="left">
205     <p>Keyword omitted.</td>
206   </tr>
207   <tr>
208     <td width="35%" align="left">
209     <p>R-value references</td>
210     <td width="65%" align="left">
211     <p>Function signature omitted.</td>
212   </tr>
213   <tr>
214     <td width="35%" align="left">
215     <p>New character types</td>
216     <td width="65%" align="left">
217     <p>The <code>boost::filesystem</code> interface doesn't use the
218     new types directly. It does use <code>u16string</code> and <code>u32string</code>
219     in namespace <code>boost</code>. These are typedefs to <code>std::u16string</code>
220     and <code>std::u32string</code> for C++11, or to <code>
221     std::basic_string&lt;boost::u16_t&gt;</code> and <code>
222     std::basic_string&lt;boost::u32_t&gt;</code> for C++03.</td>
223   </tr>
224   <tr>
225     <td width="35%" align="left">
226     <p>Defaulted and deleted functions</td>
227     <td width="65%" align="left">
228     <p>Workaround replacement functions provided.</td>
229   </tr>
230   <tr>
231     <td width="35%" align="left">
232     <p>Initializer lists</td>
233     <td width="65%" align="left">
234     <p>Not currently used.</td>
235   </tr>
236   <tr>
237     <td width="35%" align="left">
238     <p>Variadic templates</td>
239     <td width="65%" align="left">
240     <p>Not currently used.</td>
241   </tr>
242   <tr>
243     <td width="35%" align="left">
244     <p>Range-based for statements</td>
245     <td width="65%" align="left">
246     <p>Supporting functions always provided; they do no harm even for C++03
247     compilers.</td>
248   </tr>
249 </table>
250 </blockquote>
251
252
253
254 <h2><a name="Conformance">Conformance</a> [fs.conformance]</h2>
255
256 <h3>ISO/IEC 9945 conformance [fs.conform.9945]</h3>
257 <p>Some behavior in this reference documentation is specified by reference to ISO/IEC 9945. How such behavior is actually implemented is unspecified.</p>
258 <blockquote>
259 <p>[<i>Note:</i> This constitutes an &quot;as if&quot; rule for implementation of
260 operating system dependent behavior. In practice implementations will usually call native
261 operating system API's. <i>—end note</i>]</p>
262 </blockquote>
263 <p>Implementations are encouraged to provide such behavior
264
265 as it is defined by ISO/IEC 9945. Implementations shall document any
266 behavior that differs from the behavior defined by ISO/IEC 9945. Implementations that do not support exact
267 ISO/IEC 9945 behavior are
268 encouraged to provide behavior as close to ISO/IEC 9945 behavior as is reasonable given the
269 limitations of actual operating systems and file systems. If an implementation cannot provide any
270 reasonable behavior, the implementation shall report an error in an
271 implementation-defined manner.</p>
272 <blockquote>
273 <p>[<i>Note:</i> Such errors might be reported by an #error directive, a <code>
274 static_assert</code>, a <code>filesystem_error</code> exception, a special
275 return value, or some other manner. <i>—end note</i>]</p>
276 </blockquote>
277 <p>Implementations are not required to provide behavior that is not supported by
278 a particular file system.</p>
279 <blockquote>
280 <p>[<i>Example:</i> The <a href="http://en.wikipedia.org/wiki/FAT_filesystem">
281 FAT file system</a> used by some memory cards, camera memory, and floppy discs
282 does not support hard links, symlinks, and many other features of more capable
283 file systems. Implementations are only required to support the FAT features
284 supported by the host operating system. <i>—end example</i>]</p>
285 </blockquote>
286 <p>The behavior of functions described in this
287 reference
288 may differ from their specification in
289 the presence of <a href="#file-system-race">file system races</a>. No diagnostic is required.</p>
290 <p>If the possibility of a file system race would make it unreliable for a program to
291 test for a precondition before calling a function described in this reference documentation, <i>
292 Requires</i> is not specified for the condition. Instead, the condition is
293 specified as a <i>Throws</i> condition.</p>
294 <blockquote>
295 <p>[<i>Note:</i> As a design practice, preconditions are not specified when it
296 is unreasonable for a program to detect them prior to calling the function. <i>
297 —end note</i>]</p>
298 </blockquote>
299 <h3>Operating system dependent conformance [fs.conform.os]</h3>
300 <p>Some behavior is specified in this reference documentation as being
301 operating system dependent ([fs.def.osdep]). The operation system an
302 implementation is dependent upon is implementation defined.</p>
303 <p>It is permissible for an implementation to be dependent upon an operating
304 system emulator rather than the actual operating system.</p>
305 <blockquote>
306 <p>[<i>Example:</i> An implementation uses Cygwin, a Linux&reg; API emulator for
307 some Windows&reg; operating system versions. The implementation would define Cygwin
308 as its operating system. Users could refer to the Cygwin documentation to find
309 details of the operating system dependent behavior.&nbsp; <i>—end example</i>]</p>
310 <p><span style="background-color: #E0E0E0"><i>It is user and conformance test
311 detectable that such an implementation is running on Cygwin. Users would be
312 misled and conformance tests would fail if the implementation defined Linux or
313 Windows rather than Cygwin as the operating system, since real behavior is a
314 blend of the two.</i></span> </p>
315 </blockquote>
316 <h2><a name="Definitions">Definitions</a> [fs.definitions]</h2>
317 <p>The following definitions  shall apply throughout this reference documentation:</p>
318 <h3><a name="operating system dependent">operating system dependent</a> behavior
319 [fs.def.osdep]</h3>
320 <p>Behavior  that is dependent upon the behavior
321 and characteristics of an operating system. See [fs.conform.os].</p>
322 <h3><a name="file">file</a> [fs.def.file]</h3>
323 <p>An object that can be written to, or read from, or both. A file
324 has certain attributes, including type. File types include regular files
325 and directories. Other types of files, such as symbolic links, may be supported by the
326 implementation.</p>
327 <h3><a name="file-system">file system</a> [fs.def.filesystem]</h3>
328 <p>A collection of files and certain of their attributes.</p>
329 <h3><a name="filename">filename</a> [fs.def.filename]</h3>
330   <p>The name of a file. Filenames <code>
331   &quot;.&quot;</code>&nbsp;
332 and <code>&quot;..&quot;</code>&nbsp; have special meaning. The follow characteristics of
333   filenames are operating system dependent:</p>
334 <ul>
335   <li>
336   <p>The permitted characters. See [<a href="#Operating-system-examples">fs.os.examples</a>].</p>
337   </li>
338   <li>
339   <p>Specific filenames that are not permitted.</p>
340   </li>
341   <li>
342   <p>Additional filenames that have special meaning.</p>
343   </li>
344   <li>
345   <p>Case awareness and sensitivity during path resolution.</p>
346   </li>
347   <li>
348   <p>Special rules that may apply to file types other than regular
349   files, such as directories.</p>
350   </li>
351 </ul>
352 <h3><a name="path">path</a> [fs.def.path]</h3>
353 <p>A sequence of elements that identify
354 the location of a file within a filesystem. The elements are the <i>root-name<sub>opt</sub></i>, <i>
355 root-directory<sub>opt</sub></i>, and an optional sequence of filenames. [<i>Note:</i>
356 A <a href="#pathname">pathname</a> is the concrete representation of a path. <i>—end note</i>]</p>
357
358 <h3><a name="Absolute-path">absolute path</a> [fs.def.absolute-path]</h3>
359 <p>A path that
360 unambiguously
361 identifies the location of a file without reference to an additional starting
362 location. The elements of a path that determine if it is absolute are
363 operating system dependent.</p>
364
365 <h3><a name="Relative-path">relative path</a> [fs.def.relative-path]</h3>
366 <p>A path that
367 is not absolute, and so only
368 unambiguously
369 identifies the location of a file when resolved relative to
370 an implied starting location. The elements of a path that determine if it is
371 relative are operating system dependent.&nbsp; [<i>Note:</i>
372 Paths <code>&quot;.&quot;</code> and <code>&quot;..&quot;</code> are relative paths. <i>—end note</i>]</p>
373 <h3><a name="canonical-path">canonical path</a> [fs.def.canonical-path]</h3>
374 <p>An absolute path that has
375 no elements that are symbolic links, and no <code>&quot;.&quot;</code> or <code>&quot;..&quot;</code> elements.</p>
376 <h3><a name="pathname">pathname</a> [fs.def.pathname]</h3>
377 <p>A character string that represents
378 the name of a
379 path. Pathnames are formatted according to the generic pathname grammar or an
380 operating system dependent
381 native pathname format.</p>
382
383 <h3><a name="native-pathname-format">native pathname format</a> [fs.def.native]</h3>
384 <p>The operating system dependent pathname format accepted by the host operating system.</p>
385 <h3><a name="normal-form">normal form</a> path [fs.def.normal]</h3>
386 <p>A path with no redundant current directory (<i>dot</i>) or parent directory (<i>dot-dot</i>)
387 elements. The normal form for an empty path is an empty path. The normal form
388 for a path ending in a <i>directory-separator</i> that is not the root directory
389 is the same path with a current directory (<i>dot</i>) element appended.</p>
390 <h3><a name="link">link</a> [fs.def.link]</h3>
391 <p>A directory entry object that associates a
392 filename with a file. On some file systems, several directory entries can
393 associate names with the same file.</p>
394 <h3><a name="hard-link">hard link</a> [fs.def.hardlink]</h3>
395 <p>A link to an existing file. Some
396 file systems support multiple hard links to a file. If the last hard link to a
397 file is removed, the file itself is removed.</p>
398 <blockquote>
399 <p>[<i>Note:</i> A hard link can be thought of as a shared-ownership smart
400 pointer to a file.<i> â€”end note</i>]<i> </i></p>
401 </blockquote>
402 <h3><a name="symbolic-link">symbolic link</a> [fs.def.symlink]</h3>
403 <p>A type of file with the
404 property that when the file is encountered during pathname resolution, a string
405 stored by the file is used to modify the pathname resolution.</p>
406 <blockquote>
407 <p>[<i>Note:</i> A symbolic link can be thought of as a raw pointer to a file.
408 If the file pointed to does not exist, the symbolic link is said to be a
409 &quot;dangling&quot; symbolic link.<i> â€”end note</i>]<i> </i></p>
410 </blockquote>
411 <h3><a name="file-system-race">file system race</a> [fs.def.race]</h3>
412 <p>The condition that occurs
413 when multiple threads, processes, or computers interleave access and
414 modification of
415 the same object within a file system.</p>
416 <h2><a name="generic-pathname-format">Generic pathname format</a> [path.generic]</h2>
417 <p><i>pathname:<br>
418 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; root-name<sub>opt</sub>
419 root-directory<sub>opt</sub> relative-path<sub>opt</sub></i></p>
420 <p><i>root-name:<br>
421 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </i>An
422 operating system dependent name that identifies the starting location for
423 absolute paths. </p>
424 <blockquote>
425   <blockquote>
426 <p>[<i>Note:</i> Many operating systems define a name
427 beginning with two <i>directory-separator</i> characters as a <i>root-name</i>
428 that identifies network or other resource locations. Some operating systems define a single letter followed by a colon as a drive
429 specifier - a <i>root-name</i> identifying a specific device such as a disc drive. <i>—end note</i>]</p>
430   </blockquote>
431 </blockquote>
432 <p><i>root-directory:<br>
433 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
434 directory-separator</i></p>
435 <p><i>relative-path:<br>
436 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
437 filename<br>
438 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; relative-path
439 directory-separator<br>
440 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; relative-path
441 directory-separator filename</i></p>
442 <p><i>filename:<br>
443 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name<br>
444 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </i><code>&quot;.&quot;</code><i><br>
445 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </i><code>
446 &quot;..&quot;</code></p>
447 <p><i>preferred-separator:<br>
448 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </i>An
449 operating system dependent directory separator character. May be a synonym for <i> <code>&quot;/&quot;</code>.</i></p>
450 <p><i>directory-separator:<br>
451 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <code>&quot;/&quot;<br>
452 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;/&quot;</code> directory-separator<br>
453 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
454 preferred-separator<br>
455 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
456 preferred-separator directory-separator</i></p>
457 <p>Multiple successive <i>directory-separator</i> characters are considered to
458 be the same as one <i>directory-separator</i> character.</p>
459 <p>The <i>filename</i>
460 <code>&quot;.&quot;</code> is considered to be a reference to the current directory. The
461 <i>filename</i> <code>&quot;..&quot;</code> is considered to be a reference to the
462 parent
463 directory. Specific <i>filenames</i> may have special meanings for a particular
464 operating system.</p>
465 <h2><a name="Operating-system-examples">Operating system dependent examples</a> (Informative) [fs.os.examples]</h2>
466 <p>Certain features are specified in this reference documentation as being operating system dependent. The following table shows the application of those
467 specifications for operating systems that use the ISO/IEC 9945  or Windows&reg; application program interfaces
468 (APIs).<sup>[footnote1]</sup></p>
469 <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
470   <tr>
471     <td valign="top" align="center">
472     <p><b>Feature</b></td>
473     <td valign="top" align="center">
474     <p><b>Section</b></td>
475     <td valign="top" align="center">
476     <p><b>ISO/IEC 9945<br>
477 &nbsp;POSIX</b>&reg;<b> API</b></td>
478     <td valign="top" align="center">
479     <p><b>Windows</b>&reg;<b> API</b></td>
480     <td valign="top" align="center">
481     <p><b>Notes</b></td>
482   </tr>
483   <tr>
484     <td valign="top">
485     <p><code>path<br>
486 &nbsp;::value_type</code></td>
487     <td valign="top">
488     <p>[<a href="#class-path">class.path</a>]</td>
489     <td valign="top">
490     <p><code>char</code></td>
491     <td valign="top">
492     <p><code>wchar_t</code></td>
493     <td valign="top">
494     <p>&nbsp;</td>
495   </tr>
496   <tr>
497     <td valign="top">
498     <p><code>path::preferred<br>
499 &nbsp;_separator</code></td>
500     <td valign="top">
501     <p>[<a href="#class-path">class.path</a>]</td>
502     <td valign="top">
503     <p><code>'/'</code></td>
504     <td valign="top">
505     <p><code>L'\\'</code> (single backslash)</td>
506     <td valign="top">
507     <p>&nbsp;</td>
508   </tr>
509   <tr>
510     <td valign="top">
511     <p><code>path(&quot;/&quot;)<br>
512 &nbsp;.is_absolute()<br>
513     path(&quot;c:/&quot;)<br>
514 &nbsp;.is_absolute()</code></td>
515     <td valign="top">
516     <p>[<a href="#path-query">path</a><br>
517 &nbsp;<a href="#path-query">.query</a>]</td>
518     <td valign="top">
519     <p><code><br>
520     true<br>
521     <br>
522     false</code></td>
523     <td valign="top">
524     <p><code><br>
525     false<br>
526     <br>
527     true</code></td>
528     <td valign="top">
529     <p>&nbsp;</td>
530   </tr>
531   <tr>
532     <td valign="top">
533     <p><code>path</code> argument disambiguation between generic format and
534     native format</td>
535     <td valign="top">
536     <p>[<a href="#path-Conversions-to-native-format">path.arg</a><br>
537 &nbsp;<a href="#path-Conversions-to-native-format">.fmt.cvt</a>]</td>
538     <td valign="top">
539     <p>Not required</td>
540     <td valign="top">
541     <p>Not required</td>
542     <td valign="top">
543     <p>There is no need to distinguish between the generic format and native
544     format for these operating systems.</td>
545   </tr>
546   <tr>
547     <td valign="top">
548     <p><code>path</code> argument format conversion</td>
549     <td valign="top">
550     <p>[<a href="#path-Conversions-to-native-format">path.arg</a><br>
551 &nbsp;<a href="#path-Conversions-to-native-format">.fmt.cvt</a>]</td>
552     <td valign="top">
553     <p>No conversion performed</td>
554     <td valign="top">
555     <p>No conversion performed</td>
556     <td valign="top">
557     <p>The generic format is already acceptable to the native API of these operating systems.</td>
558   </tr>
559   <tr>
560     <td valign="top">
561     <p><code>path<br>
562 &nbsp;(&quot;/cats/jane&quot;)<br>
563 &nbsp;.c_str()<br>
564     path|<br>
565 &nbsp;(&quot;/cats/jane/&quot;)<br>
566 &nbsp;.c_str()</code></td>
567     <td valign="top">
568     <p>[<a href="#path-Conversions-to-native-format">path.arg</a><br>
569 &nbsp;<a href="#path-Conversions-to-native-format">.fmt.cvt</a>]</td>
570     <td valign="top">
571     <p> <code><br>
572     <br>
573     &quot;/cats/jane&quot;<br>
574     <br>
575     <br>
576     &quot;/cats/jane/&quot;</code></td>
577     <td valign="top">
578     <p><code><br>
579     <br>
580     L&quot;/cats/jane&quot;<br>
581     <br>
582     <br>
583     L&quot;/cats/jane/&quot;</code></td>
584     <td valign="top">
585     <p>These operating systems accept the same native separator between
586     directory names and a final file name, so no format conversion is performed.
587     Other operating systems might require conversion.</td>
588   </tr>
589   <tr>
590     <td valign="top">
591     <p>Format conversion by <code>path</code> native format observers</td>
592     <td valign="top">
593     <p>[<a href="#path-native-format-observers">path.native</a><br>
594 &nbsp;<a href="#path-native-format-observers">.obs</a>]</td>
595     <td valign="top">
596     <p>No conversion performed</td>
597     <td valign="top">
598     <p>No conversion performed</td>
599     <td valign="top">
600     <p>For efficiency, <code>path</code> objects are required to store pathnames in the native
601     format regardless of operating system.</td>
602   </tr>
603   <tr>
604     <td valign="top">
605     <p>Format conversion by <code>path</code> generic format observers</td>
606     <td valign="top">
607     <p>[<a href="#path-generic-format-observers">path</a><br>
608 &nbsp;<a href="#path-generic-format-observers">.generic</a><br>
609 &nbsp;<a href="#path-generic-format-observers">.obs</a>]</td>
610     <td valign="top">
611     <p>No conversion performed</td>
612     <td valign="top">
613     <p>Backslashes converted to slashes</td>
614     <td valign="top">
615     <p>&nbsp;</td>
616   </tr>
617   <tr>
618     <td valign="top">
619     <p><code>p.<br>
620 &nbsp;make_preferred()</code></td>
621     <td valign="top">
622     <p>[<a href="#path-modifiers">fs.path</a><br>
623 &nbsp;<a href="#path-modifiers">.modifiers</a>]</td>
624     <td valign="top">
625     <p>No change</td>
626     <td valign="top">
627     <p>Slashes converted to backslashes</td>
628     <td valign="top">
629     <p>&nbsp;</td>
630   </tr>
631   <tr>
632     <td valign="top">
633     <p>Characters prohibited in filenames</td>
634     <td valign="top">
635     <p>[<a href="#filename">fs.def</a><br>
636 &nbsp;<a href="#filename">.filename</a>]</td>
637     <td valign="top">
638     <p>0x00, <code>'/'</code></td>
639     <td valign="top">
640     <p>0x00-0x1F, <code>'&quot;'</code>, <code>'*'</code>,<code>&nbsp;'*'</code>,
641     <code>'&lt;'</code>,
642     <code>'&gt;'</code>, <code>'?'</code>, <code>'\\'</code> (single backslash),
643     <code>'/'</code>, <code>'|'</code></td>
644     <td valign="top">
645     <p>Many operating systems prohibit the ASCII control characters (0x00-0x1F)
646     in filenames.</td>
647   </tr>
648   <tr>
649     <td valign="top">
650     <p>Initial imbued <code>path</code> locale</td>
651     <td valign="top">
652     <p>[<a href="#path-imbued-locale">path</a><br>
653 &nbsp;<a href="#path-imbued-locale">.imbued</a><br>
654 &nbsp;<a href="#path-imbued-locale">.locale</a>]</td>
655     <td valign="top">
656     <p> <code>std::<br>
657 &nbsp; locale(&quot;&quot;)<br>
658     </code><sup>[footnote 2]</sup></td>
659     <td valign="top">
660     <p>Implementation supplied locale using <code>MultiByte<br>
661 &nbsp; ToWideChar</code>
662     and <code>WideChar<br>
663 &nbsp; ToMultiByte</code> with a codepage of <code>CP_ACP</code>
664     if <code>AreFileApisANSI</code> is true, otherwise codepage <code>CP_OEMCP</code>.<sup>[footnote
665     3]</sup></td>
666     <td valign="top">
667     <p>Apple OS X&reg;:&nbsp; Implementation supplied locale providing UTF-8 <code>codecvt</code>
668     facet.<sup>[footnote 4]</sup></td>
669   </tr>
670 </table>
671 <p><sup>[footnote1]</sup> OS X&reg; and Windows&reg; are examples of commercially
672 available operating systems. This information is given for the convenience of
673 users of this document and does not constitute an endorsement by ISO or IEC of
674 these products.</p>
675 <p><sup>[footnote 2] </sup>Rationale: ISO C specifies <code>std::locale(&quot;&quot;)</code> as &quot;the locale-specific native
676 environment&quot;, while ISO/IEC 9945 says it &quot;Specifies an implementation-defined native
677 environment.&quot;</p>
678 <p><sup>[footnote 3] </sup>Rationale: This is the current behavior of C and C++
679 standard library functions that perform file operations using narrow character
680 strings to identify paths. Changing this behavior would be surprising and at
681 variance with existing code, particularly where user input is involved.</p>
682 <p><sup>[footnote 4]</sup> Rationale: Vendor's documentation states &quot;All BSD
683 system functions expect their string parameters to be in UTF-8 encoding and
684 nothing else.&quot;</p>
685 <h2><a name="Header-filesystem-synopsis">Header <code>&lt;boost/filesystem.hpp&gt;</code> synopsis</a>
686 [filesystem.synopsis]</h2>
687
688
689
690 <pre>namespace boost
691 {
692   namespace filesystem
693   {
694     class <a href="#class-path">path</a>;
695
696     bool lexicographical_compare(path::iterator first1, path::iterator last1,
697       path::iterator first2, path::iterator last2);
698     void swap(path&amp; lhs, path&amp; rhs);
699     std::size_t <a href="#hash_value">hash_value</a>(const path&amp; p);
700
701     bool operator==(const path&amp; lhs, const path&amp; rhs);
702     bool operator!=(const path&amp; lhs, const path&amp; rhs);
703     bool operator&lt; (const path&amp; lhs, const path&amp; rhs);
704     bool operator&lt;=(const path&amp; lhs, const path&amp; rhs);
705     bool operator&gt; (const path&amp; lhs, const path&amp; rhs);
706     bool operator&gt;=(const path&amp; lhs, const path&amp; rhs);
707
708     path operator/ (const path&amp; lhs, const path&amp; rhs);
709
710     std::ostream&amp;  operator&lt;&lt;( std::ostream&amp; os, const path&amp; p );
711     std::wostream&amp; operator&lt;&lt;( std::wostream&amp; os, const path&amp; p );
712     std::istream&amp;  operator&gt;&gt;( std::istream&amp; is, path&amp; p );
713     std::wistream&amp; operator&gt;&gt;( std::wistream&amp; is, path&amp; p )
714
715     class <a href="#Class-filesystem_error">filesystem_error</a>;
716     class <a href="#Class-directory_entry">directory_entry</a>;
717
718     class <a href="#Class-directory_iterator">directory_iterator</a>;
719
720     // enable c++11 range-based for statements
721     const directory_iterator&amp; <a href="#directory_iterator-non-member-functions">begin</a>(const directory_iterator&amp; iter);
722     directory_iterator <a href="#directory_iterator-non-member-functions">end</a>(const directory_iterator&amp;);
723
724
725     // enable BOOST_FOREACH
726     directory_iterator&amp; range_begin(directory_iterator&amp; iter);
727     directory_iterator range_begin(const directory_iterator&amp; iter);
728     directory_iterator range_end(const directory_iterator&amp;);
729
730     class <a href="#Class-recursive_directory_iterator">recursive_directory_iterator</a>;
731
732     // enable c++11 range-based for statements
733     const recursive_directory_iterator&amp;
734       <a href="#recursive_directory_iterator-non-member-functions">begin</a>(const recursive_directory_iterator&amp; iter);
735     recursive_directory_iterator
736       <a href="#recursive_directory_iterator-non-member-functions">end</a>(const recursive_directory_iterator&amp;);
737
738
739     // enable BOOST_FOREACH
740     recursive_directory_iterator&amp;
741       range_begin(recursive_directory_iterator&amp; iter);
742     recursive_directory_iterator
743       range_begin(const recursive_directory_iterator&amp; iter);
744     recursive_directory_iterator
745       range_end(const recursive_directory_iterator&amp;);
746
747     enum <a name="file_type" href="#Enum-file_type">file_type</a>
748     {
749       status_error, file_not_found, regular_file, directory_file,
750       symlink_file, block_file, character_file, fifo_file, socket_file,
751       type_unknown
752     };
753
754     enum <a href="#Enum-perms">perms</a>
755     {
756       no_perms,
757       owner_read, owner_write, owner_exe, owner_all,
758       group_read, group_write, group_exe, group_all,
759       others_read, others_write, others_exe, others_all, all_all,
760       set_uid_on_exe, set_gid_on_exe, sticky_bit,
761       perms_mask, perms_not_known,
762       add_perms, remove_perms, symlink_perms
763     };
764
765     class <a href="#file_status">file_status</a>;
766
767     struct <a name="space_info">space_info</a>  // returned by <a href="#space" style="text-decoration: none">space</a> function
768     {
769       uintmax_t capacity;
770       uintmax_t free;
771       uintmax_t available; // free space available to non-privileged process
772     };
773
774     enum class <a name="copy_option">copy_option</a>
775     {
776       none
777       fail_if_exists = none,
778       overwrite_if_exists
779     };
780
781     enum class <a name="directory_options">directory_options</a>
782     {
783       none
784       skip_permission_denied,
785       follow_directory_symlink,
786       pop_on_error
787     };
788
789     // Deprecated, use <a href="#directory_options">directory_options</a> instead
790     enum class <a name="symlink_option">symlink_option</a>
791     {
792       none = directory_options::none
793       no_recurse = none,
794       recurse = directory_options::follow_directory_symlink
795     };
796
797     // <a href="#Operational-functions">operational functions</a>
798
799     path         <a href="#absolute">absolute</a>(const path&amp; p, const path&amp; base=current_path());
800
801     path         <a href="#canonical">canonical</a>(const path&amp; p, const path&amp; base = current_path());
802     path         <a href="#canonical">canonical</a>(const path&amp; p, system::error_code&amp; ec);
803     path         <a href="#canonical">canonical</a>(const path&amp; p, const path&amp; base,
804                    system::error_code&amp; ec);
805
806     void         <a href="#copy">copy</a>(const path&amp; from, const path&amp; to);
807     void         <a href="#copy">copy</a>(const path&amp; from, const path&amp; to,
808                    system::error_code&amp; ec);
809
810     void         <a href="#create_directory">copy_directory</a>(const path&amp; from, const path&amp; to);
811     void         <a href="#create_directory">copy_directory</a>(const path&amp; from, const path&amp; to,
812                    system::error_code&amp; ec);
813
814     void         <a href="#copy_file">copy_file</a>(const path&amp; from, const path&amp; to);
815     void         <a href="#copy_file">copy_file</a>(const path&amp; from, const path&amp; to,
816                    system::error_code&amp; ec);
817     void         <a href="#copy_file">copy_file</a>(const path&amp; from, const path&amp; to,
818                    <a href="#copy_option">copy_option</a> option);
819     void         <a href="#copy_file">copy_file</a>(const path&amp; from, const path&amp; to,
820                    <a href="#copy_option">copy_option</a> option, system::error_code&amp; ec);
821
822     void         <a href="#copy_symlink">copy_symlink</a>(const path&amp; existing_symlink,
823                    const path&amp; new_symlink);
824     void         <a href="#copy_symlink">copy_symlink</a>(const path&amp; existing_symlink,
825                    const path&amp; new_symlink, system::error_code&amp; ec);
826
827     bool         <a href="#create_directories">create_directories</a>(const path&amp; p);
828     bool         <a href="#create_directories">create_directories</a>(const path&amp; p,
829                    system::error_code&amp; ec);
830
831     bool         <a href="#create_directory">create_directory</a>(const path&amp; p);
832     bool         <a href="#create_directory">create_directory</a>(const path&amp; p, system::error_code&amp; ec);
833
834     void         <a href="#create_directory_symlink">create_directory_symlink</a>(const path&amp; to,
835                    const path&amp; new_symlink);
836     void         <a href="#create_directory_symlink">create_directory_symlink</a>(const path&amp; to,
837                    const path&amp; new_symlink, system::error_code&amp; ec);
838
839     void         <a href="#create_hard_link">create_hard_link</a>(const path&amp; to, const path&amp; new_hard_link);
840     void         <a href="#create_hard_link">create_hard_link</a>(const path&amp; to, const path&amp; new_hard_link,
841                                   system::error_code&amp; ec);
842
843     void         <a href="#create_symlink">create_symlink</a>(const path&amp; to, const path&amp; new_symlink);
844     void         <a href="#create_symlink">create_symlink</a>(const path&amp; to, const path&amp; new_symlink,
845                                 system::error_code&amp; ec);
846
847     path         <a href="#current_path">current_path</a>();
848     path         <a href="#current_path">current_path</a>(system::error_code&amp; ec);
849     void         <a href="#current_path">current_path</a>(const path&amp; p);
850     void         <a href="#current_path">current_path</a>(const path&amp; p, system::error_code&amp; ec);
851
852     bool         <a href="#exists">exists</a>(file_status s) noexcept;
853     bool         <a href="#exists">exists</a>(const path&amp; p);
854     bool         <a href="#exists">exists</a>(const path&amp; p, system::error_code&amp; ec) noexcept;
855
856     bool         <a href="#equivalent">equivalent</a>(const path&amp; p1, const path&amp; p2);
857     bool         <a href="#equivalent">equivalent</a>(const path&amp; p1, const path&amp; p2,
858                    system::error_code&amp; ec);
859
860     uintmax_t    <a href="#file_size">file_size</a>(const path&amp; p);
861     uintmax_t    <a href="#file_size">file_size</a>(const path&amp; p, system::error_code&amp; ec);
862
863     uintmax_t    <a href="#hard_link_count">hard_link_count</a>(const path&amp; p);
864     uintmax_t    <a href="#hard_link_count">hard_link_count</a>(const path&amp; p, system::error_code&amp; ec);
865
866     const path&amp;  <a href="#initial_path">initial_path</a>();
867     const path&amp;  <a href="#initial_path">initial_path</a>(<code>system::error_code&amp; ec</code>);
868
869     bool         <a href="#is_directory">is_directory</a>(file_status s) noexcept;
870     bool         <a href="#is_directory2">is_directory</a>(const path&amp; p);
871     bool         <a href="#is_directory2">is_directory</a>(const path&amp; p,
872                    system::error_code&amp; ec) noexcept;
873
874     bool         <a href="#is_empty">is_empty</a>(const path&amp; p);
875     bool         <a href="#is_empty">is_empty</a>(const path&amp; p, system::error_code&amp; ec);
876
877     bool         <a href="#is_other">is_other</a>(file_status s) noexcept;
878     bool         <a href="#is_other2">is_other</a>(const path&amp; p,);
879     bool         <a href="#is_other2">is_other</a>(const path&amp; p, system::error_code&amp; ec) noexcept;
880
881     bool         <a href="#is_regular_file">is_regular_file</a>(file_status s) noexcept;
882     bool         <a href="#is_regular_file2">is_regular_file</a>(const path&amp; p);
883     bool         <a href="#is_regular_file2">is_regular_file</a>(const path&amp; p,
884                    system::error_code&amp; ec) noexcept;
885
886     bool         <a href="#is_symlink">is_symlink</a>(file_status s noexcept);
887     bool         <a href="#is_symlink2">is_symlink</a>(const path&amp; p);
888     bool         <a href="#is_symlink2">is_symlink</a>(const path&amp; p, system::error_code&amp; ec) noexcept;
889
890     std::time_t  <a href="#last_write_time">last_write_time</a>(const path&amp; p);
891     std::time_t  <a href="#last_write_time">last_write_time</a>(const path&amp; p, system::error_code&amp; ec);
892     void         <a href="#last_write_time2">last_write_time</a>(const path&amp; p, const std::time_t new_time);
893     void         <a href="#last_write_time2">last_write_time</a>(const path&amp; p, const std::time_t new_time,
894                                  system::error_code&amp; ec);
895
896     path         <a href="#read_symlink">read_symlink</a>(const path&amp; p);
897     path         <a href="#read_symlink">read_symlink</a>(const path&amp; p, system::error_code&amp; ec);
898
899     path         <a href="#op-relative">relative</a>(const path&amp; p, system::error_code&amp; ec);
900     path         <a href="#op-relative">relative</a>(const path&amp; p, const path&amp; base=current_path());
901     path         <a href="#op-relative">relative</a>(const path&amp; p,
902                      const path&amp; base, system::error_code&amp; ec);
903
904     bool         <a href="#remove">remove</a>(const path&amp; p);
905     bool         <a href="#remove">remove</a>(const path&amp; p, system::error_code&amp; ec);
906
907     uintmax_t    <a href="#remove_all">remove_all</a>(const path&amp; p);
908     uintmax_t    <a href="#remove_all">remove_all</a>(const path&amp; p, system::error_code&amp; ec);
909
910     void         <a href="#rename">rename</a>(const path&amp; from, const path&amp; to);
911     void         <a href="#rename">rename</a>(const path&amp; from, const path&amp; to,
912                    system::error_code&amp; ec);
913
914     void         <a href="#resize_file">resize_file</a>(const path&amp; p, uintmax_t size);
915     void         <a href="#resize_file2">resize_file</a>(const path&amp; p, uintmax_t size,
916                    system::error_code&amp; ec);
917
918     <a href="#space_info">space_info</a>   <a href="#space">space</a>(const path&amp; p);
919     <a href="#space_info">space_info</a>   <a href="#space">space</a>(const path&amp; p, system::error_code&amp; ec);
920
921     <a href="#file_status">file_status</a>  <a href="#status">status</a>(const path&amp; p);
922     <a href="#file_status">file_status</a>  <a href="#status">status</a>(const path&amp; p, system::error_code&amp; ec) noexcept;
923
924     bool         <a href="#status_known">status_known</a>(file_status s) noexcept;
925
926     <a href="#file_status">file_status</a>  <a href="#symlink_status">symlink_status</a>(const path&amp; p);
927     <a href="#file_status">file_status</a>  <a href="#symlink_status">symlink_status</a>(const path&amp; p,
928                    system::error_code&amp; ec) noexcept;
929
930     path         <a href="#system_complete">system_complete</a>(const path&amp; p);
931     path         <a href="#system_complete">system_complete</a>(const path&amp; p, system::error_code&amp; ec);
932
933     path         <a href="#temp_directory_path">temp_directory_path</a>();
934     path         <a href="#temp_directory_path">temp_directory_path</a>(system::error_code&amp; ec);
935
936     path         <a href="#unique_path">unique_path</a>(const path&amp; model=&quot;%%%%-%%%%-%%%%-%%%%&quot;);
937     path         <a href="#unique_path">unique_path</a>(const path&amp; model, system::error_code&amp; ec);
938
939     path         <a href="#weakly_canonical">weakly_canonical</a>(const path&amp; p);
940     path         <a href="#weakly_canonical">weakly_canonical</a>(const path&amp; p, system::error_code&amp; ec);
941
942   }  // namespace filesystem
943 }  // namespace boost</pre>
944
945
946
947 <h2><a name="Error-reporting">Error reporting</a> [fs.err.report]</h2>
948 <p>Filesystem library functions often provide two overloads, one that
949 throws an exception to report file system errors, and another that sets an <code>error_code</code>.</p>
950 <blockquote>
951 <p>[<i>Note:</i> This supports two common use cases:</p>
952 <ul>
953   <li>
954   <p>Uses where file system
955 errors are truly exceptional and indicate a serious failure. Throwing an
956   exception is the most appropriate response. This is the preferred default for
957   most everyday programming.<br>
958 &nbsp;</li>
959   <li>
960   <p>Uses where file system errors are routine and do not necessarily represent
961   failure. Returning an error code is the most appropriate response. This allows
962   application specific error handling, including simply ignoring the error.</li>
963 </ul>
964   <p><i>—end note</i>]</p>
965 </blockquote>
966 <p>Functions <b>not</b> having an argument of type <code>system::error_code&amp;</code> report errors as follows, unless otherwise specified:</p>
967   <ul>
968   <li>
969   <p>When a call by the
970   implementation to an operating system or other underlying API results in an
971   error that prevents the function from meeting its specifications, an exception
972   of type
973 <code>filesystem_error</code> is thrown.<br>
974 &nbsp;</li>
975   <li>
976   <p>Failure to allocate storage is reported by throwing an exception as described in the C++ standard,
977   17.6.4.10 [res.on.exception.handling].<br>
978 &nbsp;</li>
979   <li>
980   <p>Destructors throw nothing.</li>
981   </ul>
982   <p>Functions having an argument of type <code>system::error_code&amp;</code> report errors as follows, unless otherwise
983   specified:</p>
984 <ul>
985   <li>
986   <p>If a call by the
987   implementation to an operating system or other underlying API results in an
988   error that prevents the function from meeting its specifications, the
989 <code>system::error_code&amp;</code> argument is set as
990   appropriate for the specific error. Otherwise, <code>clear()</code>
991   is called on the
992 <code>system::error_code&amp;</code> argument.<br>
993 &nbsp;</li>
994   <li>
995   <p>Failure to allocate storage is reported by
996   throwing an exception as described in the C++ standard,
997   17.6.4.10 [res.on.exception.handling].</li>
998 </ul>
999 <h2><a name="class-path">Class <code>path</code> [class.path]</a></h2>
1000 <p>An object of class <code>path</code> represents a <a href="#path">path</a>,
1001 and contains a <a href="#pathname">pathname</a> Such an object is concerned only with the lexical and syntactic aspects
1002 of a path. The path does not necessarily exist in external storage, and the
1003 pathname is not necessarily valid for the current operating
1004 system or for a particular file system.</p>
1005
1006 <div dir="ltr">
1007
1008 <pre>namespace boost
1009 {
1010   namespace filesystem
1011   {
1012       class path
1013       {
1014       public:
1015         typedef <b><i><a href="#value_type">see below</a></i></b>                                    value_type;
1016         typedef std::basic_string&lt;value_type&gt;                string_type;
1017         typedef std::codecvt&lt;wchar_t, char, std::mbstate_t&gt;  codecvt_type;
1018         constexpr value_type                                 dot;
1019         constexpr value_type                                 separator;
1020         constexpr value_type                                 preferred_separator;
1021
1022         // <a href="#path-constructors">constructors</a> and destructor
1023         path();
1024         path(const path&amp; p);
1025         path(path&amp;&amp; p) noexcept;
1026
1027         template &lt;class <a href="#Source">Source</a>&gt;
1028           path(Source const&amp; source, const codecvt_type&amp; cvt=codecvt());
1029
1030         template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
1031           path(InputIterator begin, InputIterator end,
1032             const codecvt_type&amp; cvt=codecvt());
1033
1034        ~path();
1035
1036         // <a href="#path-assignments">assignments</a>
1037         path&amp; operator=(const path&amp; p);
1038         path&amp; operator=(path&amp;&amp; p) noexcept;
1039
1040         template &lt;class <a href="#Source">Source</a>&gt;
1041           path&amp; operator=(Source const&amp; source);
1042
1043         template &lt;class <a href="#Source">Source</a>&gt;
1044           path&amp; assign(Source const&amp; source, const codecvt_type&amp; cvt)
1045
1046         template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
1047           path&amp; assign(InputIterator begin, InputIterator end,
1048             const codecvt_type&amp; cvt=codecvt());
1049
1050         // <a href="#path-appends">appends</a>
1051         path&amp; operator/=(const path&amp; p);
1052
1053         template &lt;class <a href="#Source">Source</a>&gt;
1054           path&amp; operator/=(Source const&amp; source);
1055
1056         template &lt;class <a href="#Source">Source</a>&gt;
1057           path&amp; append(Source const&amp; source, const codecvt_type&amp; cvt);
1058
1059         template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
1060           path&amp; append(InputIterator begin, InputIterator end,
1061             const codecvt_type&amp; cvt=codecvt());
1062
1063         // <a href="#path-concatenation">concatenation</a>
1064         path&amp; operator+=(const path&amp; x);
1065         path&amp; operator+=(const string_type&amp; x);
1066         path&amp; operator+=(const value_type* x);
1067         path&amp; operator+=(value_type x);
1068         template &lt;class Source&gt;
1069           path&amp; operator+=(Source const&amp; x);
1070         template &lt;class CharT&gt;
1071           path&amp; operator+=(CharT x);
1072         template &lt;class Source&gt;
1073           path&amp; concat(Source const&amp; x, const codecvt_type&amp; cvt);
1074         template &lt;class InputIterator&gt;
1075           path&amp; concat(InputIterator begin, InputIterator end);
1076         template &lt;class InputIterator&gt;
1077           path&amp; concat(InputIterator begin, InputIterator end,
1078             const codecvt_type&amp; cvt);
1079
1080         // <a href="#path-modifiers">modifiers</a>
1081         void  <a href="#path-clear">clear</a>();
1082         path&amp; <a href="#path-make_preferred">make_preferred</a>();
1083         path&amp; <a href="#path-remove_filename">remove_filename</a>();
1084         path&amp; <a href="#path-replace_extension">replace_extension</a>(const path&amp; new_extension = path());
1085         void  <a href="#path-swap">swap</a>(path&amp; rhs);
1086
1087         // lexical operations
1088         path <a href="#lexically_normal">lexically_normal</a>() const;
1089         path <a href="#lexically_relative">lexically_relative</a>(const path&amp; base) const;
1090         path <a href="#lexically_proximate">lexically_proximate</a>(const path&amp; base) const;
1091
1092         // <a href="#path-native-format-observers">native format observers</a>
1093         const string_type&amp;  <a href="#native">native</a>() const noexcept;  // native format, encoding
1094         const value_type*   <a href="#c_str">c_str</a>() const noexcept;   // native().c_str()
1095         string_type::size_type <a href="#path-size">size</a>() const noexcept; // native().size()
1096
1097         template &lt;class String&gt;
1098           String  <a href="#string-template">string</a>(const codecvt_type&amp; cvt=codecvt()) const;
1099         string    <a href="#string">string</a>(const codecvt_type&amp; cvt=codecvt()) const;
1100         wstring   <a href="#wstring">wstring</a>(const codecvt_type&amp; cvt=codecvt()) const;
1101         u16string <a href="#u16string">u16string</a>() const;
1102         u32string <a href="#u32wstring">u32string</a>() const;
1103
1104         // <a href="#path-generic-format-observers">generic format observers</a>
1105         template &lt;class String&gt;
1106           String  <a href="#generic_string-template">generic_string</a>() const;
1107
1108         string    <a href="#generic_string">generic_string</a>(const codecvt_type&amp; cvt=codecvt()) const;
1109         wstring   <a href="#generic_wstring">generic_wstring</a>(const codecvt_type&amp; cvt=codecvt()) const;
1110         u16string <a href="#generic_u16string">generic_u16string</a>()
1111         u32string <a href="#generic_u32wstring">generic_u32string</a>()
1112
1113         // <a href="#path-compare">compare</a>
1114         int   <a href="#path-compare">compare</a>(const path&amp; p) const noexcept;
1115         int   <a href="#path-compare">compare</a>(const std::string&amp; s) const;
1116         int   <a href="#path-compare">compare</a>(const value_type* s) const;
1117
1118         // <a href="#path-decomposition">decomposition</a>
1119         path  <a href="#path-root_name">root_name</a>() const;
1120         path  <a href="#path-root_directory">root_directory</a>() const;
1121         path  <a href="#path-root_path">root_path</a>() const;
1122         path  <a href="#path-relative_path">relative_path</a>() const;
1123         path  <a href="#path-parent_path">parent_path</a>() const;
1124         path  <a href="#path-filename">filename</a>() const;
1125         path  <a href="#path-stem">stem</a>() const;
1126         path  <a href="#path-extension">extension</a>() const;
1127
1128         // <a href="#path-query">query</a>
1129         bool <a href="#path-query">empty</a>() const;
1130         bool <a href="#filename_is_dot">filename_is_dot</a>() const;
1131         bool <a href="#filename_is_dot_dot">filename_is_dot_dot</a>() const;
1132         bool <a href="#path-has_root_name">has_root_name</a>() const;
1133         bool <a href="#path-has_root_directory">has_root_directory</a>() const;
1134         bool <a href="#path-has_root_path">has_root_path</a>() const;
1135         bool <a href="#path-has_relative_path">has_relative_path</a>() const;
1136         bool <a href="#path-has_parent_path">has_parent_path</a>() const;
1137         bool <a href="#path-has_filename">has_filename</a>() const;
1138         bool <a href="#path-has_stem">has_stem</a>() const;
1139         bool <a href="#path-has_extension">has_extension</a>() const;
1140         bool <a href="#path-is_absolute">is_absolute</a>() const;
1141         bool <a href="#path-is_relative">is_relative</a>() const;
1142
1143         // <a href="#path-iterators">iterators</a>
1144         class iterator;
1145         typedef iterator const_iterator;
1146         class reverse_iterator;
1147         typedef reverse_iterator const_reverse_iterator;
1148
1149         iterator begin() const;
1150         iterator end() const;
1151         reverse_iterator rbegin() const;
1152         reverse_iterator rend() const;
1153
1154         // <a href="#path-imbued-locale">imbued locale</a>
1155         static std::locale <a href="#path-imbue">imbue</a>(const std::locale&amp; loc);
1156         static const codecvt_type &amp; <a href="#path-codecvt">codecvt</a>();
1157
1158       private:
1159         string_type pathname;  // <b><i>exposition only</i></b>
1160       };
1161
1162   }  // namespace filesystem
1163 }  // namespace boost</pre>
1164
1165 </div>
1166
1167 <p><code><a name="value_type">value_type</a></code> is a <code>typedef</code> for the
1168 character type used by the operating system to represent pathnames.</p>
1169
1170
1171 <h3><a name="path-Usage"><code>path</code> Usage concerns</a> [path.usage]</h3>
1172
1173 <h4>Multithreading concerns</h4>
1174
1175 <p>Filesystem library functions are not protected against data races. [Modifying
1176 an object of a Filesystem library type that is shared between threads risks
1177 undefined behavior unless objects of that type are explicitly specified as being
1178 sharable without data races or the user supplies a locking mechanism. <i>—end
1179 note</i>] [<i>Note:</i> Thus the Filesystem library behaves as if it were part
1180 of the standard library, and C++ standard 17.6.4.10 <i>Shared objects and the
1181 library</i> [res.on.objects] would thus apply.&nbsp; <i>—end note</i>]</p>
1182
1183 <h4>Windows concerns</h4>
1184
1185 <p>Visual C++ at least through version 2012 does not employ C++11-style static
1186 initialization locks, so the initialization of <code>path::codecvt()</code> can
1187 race, either with itself or <code>path::imbue::()</code> if they are called from
1188 a different thread. A workaround is to call:</p>
1189
1190 <blockquote>
1191 <p><code>path::codecvt();&nbsp; // ensure VC++ does not race during
1192 initialization.</code></p>
1193
1194 </blockquote>
1195 <p>in the main thread before launching any additional threads. [<i>Note:</i> The
1196 obvious fix of the Filesystem implementation doing the locking doesn't work
1197 because of unrelated problems with the Microsoft compiler; for static linking
1198 the runtime tries to do the initialization before main() starts, but doesn't
1199 permit operating system lock calls at that time.&nbsp; <i>—end note</i>]</p>
1200
1201 <h4>POSIX concerns</h4>
1202
1203 <p>Filesystem library initialization may throw an exception on POSIX
1204 systems (e.g. Linux, but not Mac OS X) that use environmental variables to
1205 determine the encoding of paths. This happens when <code>std::locale(&quot;&quot;)</code>
1206 throws because an environmental variable such as LANG is set to an invalid
1207 value, so it can affect any use of&nbsp; <code>std::locale(&quot;&quot;)</code>, not just
1208 the Filesystem library. Filesystem uses lazy initialization so the exception is
1209 only thrown if a valid <code>std::locale(&quot;&quot;)</code> is actually needed, and also
1210 so that the exception is thrown after <code>main()</code> starts.</p>
1211
1212 <p>Rather than waiting until a call to some Filesystem library function
1213 unexpectedly triggers the exception when it calls <code>path::codecvt()</code>,
1214 a program that needs be highly robust against environmental variable problems
1215 may want to preemptively call <code>std::locale(&quot;&quot;)</code> within a try block,
1216 catch the exception, and diagnose or repair the invalid environmental variable.</p>
1217
1218 <h3><a name="path-Conversions"><code>path</code> Conversions</a> [path.cvt]</h3>
1219 <h4><code>path</code> argument conversions [<a name="path.arg.convert">path.arg.cvt</a>]</h4>
1220 <h5><a name="path-Conversions-to-native-format"><code>path</code> argument
1221 format conversions</a> [path.arg.fmt.cvt]</h5>
1222 <p>Member function arguments that take character sequences representing paths
1223 may use the <a href="#generic-pathname-format">generic pathname format</a> or
1224 the <a href="#native-pathname-format">native pathname format</a>. Iff such  arguments
1225 are in the generic format and the generic format is not acceptable to the
1226 operating system as a native path,  conversion to native format shall be performed
1227 during the processing of the argument. See [<a href="#Operating-system-examples">fs.os.examples</a>].</p>
1228 <blockquote>
1229 <p>[<i>Note:</i> Depending on the operating system, there may be no unambiguous way for an implementation to
1230 always be able to distinguish between native format and generic format arguments.
1231 This is by design as it simplifies use for operating systems that do not require
1232 disambiguation. Should an implementation encounter an
1233 operating system where disambiguation is required, an implementation can defined
1234 an extension to distinguish between the formats. <i>
1235 —end note</i>]</p>
1236 </blockquote>
1237
1238 <p>If the native format requires
1239 paths for regular files to be formatted differently from paths for directories, the
1240 path shall be treated as a directory path if last element is a separator,
1241 otherwise it shall be treated as a regular file path.</p>
1242
1243 <h5><a name="path-Encoding-conversions"><code>
1244 path</code> argument encoding conversions</a>
1245 [path.arg.encoding.cvt]</h5>
1246 <p>For member function arguments that take character sequences representing
1247 paths, if the value type of the argument is not <code>value_type and </code>one
1248 of the value types is <code>char</code> and the other is <code>wchar_t</code>, conversion to <code>value_type</code>
1249 shall be performed by the <code>path::codecvt()</code> facet. ([<a href="#path-imbued-locale">path.imbued.locale</a>]).</p>
1250 <h4><a name="path-Conversions-to-generic-format"><code>path</code> Conversions
1251 to generic format</a> [fs.cvt.to.generic]</h4>
1252 <p><a href="#path-generic-format-observers">Generic format observer</a> functions
1253 shall return strings formatted according to the <a href="#generic-pathname-format">generic pathname format</a>
1254 using <i>preferred-separator</i>. See [<a href="#Operating-system-examples">fs.os.examples</a>].</p>
1255 <h3><a name="path-Requirements"><code>path</code> Requirements</a> [path.req]</h3>
1256 <p>Template parameters named <code><a name="InputIterator">InputIterator</a></code> are required meet the
1257 requirements for a C++ standard library <code>RandomIterator</code> compliant iterator. The iterator's value type is required to be <code>char</code>, <code>wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</p>
1258 <p>Template parameters named <code><a name="Source">Source</a></code> are required to be one of:</p>
1259 <ul>
1260   <li>
1261   <p>A container with a value type of <code>char</code>, <code>
1262   wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</li>
1263   <li>
1264   <p>An iterator for a null terminated byte-string. The value type is required
1265   to be <code>char</code>, <code>wchar_t</code>, <code>char16_t</code>, or <code>
1266   char32_t</code>.</li>
1267   <li>
1268   <p>A C-array. The value type is required to be <code>char</code>, <code>
1269   wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</li>
1270   <li>
1271   <p>A <code>boost::filesystem::directory_entry</code>.</li>
1272 </ul>
1273
1274 <h3> <a name="path-constructors"> <code>
1275 <font size="4">path</font></code> constructors</a> [path.construct]</h3>
1276
1277 <pre>template &lt;class <a href="#Source">Source</a>&gt;
1278   path(Source const&amp; source, const codecvt_type&amp; cvt=codecvt());</pre>
1279
1280
1281 <pre>template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
1282   path(InputIterator begin, InputIterator end, const codecvt_type&amp; cvt=codecvt());</pre>
1283
1284 <blockquote>
1285   <p><i>Effects:</i> Stores the contents [<code>begin</code>,<code>end</code>)
1286   or <code>source</code> in <code>pathname</code>, converting format and
1287   encoding if required ([<a href="#path.arg.convert">path.arg.convert</a>]).</p>
1288 </blockquote>
1289 <h3> <a name="path-assignments"> <code>
1290 <font size="4">path</font></code> assignments</a> [path.assign]</h3>
1291
1292 <pre>template &lt;class <a href="#Source">Source</a>&gt;
1293   path&amp; operator=(Source const&amp; source);
1294   template &lt;class <a href="#Source">Source</a>&gt;
1295   path&amp; assign(Source const&amp; source, const codecvt_type&amp; cvt);
1296   template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
1297   path&amp; assign(InputIterator begin, InputIterator end, const codecvt_type&amp; cvt=codecvt());</pre>
1298
1299 <blockquote>
1300   <p><i>Effects:</i> Stores the contents [<code>begin</code>,<code>end</code>)
1301   or <code>source</code> in <code>pathname</code>, converting format and
1302   encoding if required ([<a href="#path.arg.convert">path.arg.convert</a>]). </p>
1303   <p>
1304   <i>Returns: </i><code>*this</code></p>
1305   </blockquote>
1306 <h3><a name="path-appends"><code><font size="4"> path</font></code> appends</a>
1307 [path.append]</h3>
1308   <p>The append operations use <code>
1309   operator/=</code> to denote their semantic effect of appending <i>
1310   preferred-separator</i> when needed. </p>
1311
1312 <pre>path&amp; operator/=(const path&amp; p);</pre>
1313
1314 <blockquote>
1315   <p><i>Effects:</i></p>
1316   <blockquote>
1317     <p>Appends <code>path::preferred_separator</code> to <code>pathname</code>,
1318     converting format and encoding if required ([<a href="#path.arg.convert">path.arg.convert</a>]), unless:</p>
1319     <ul>
1320     <li>
1321     <p>an added separator
1322     would be redundant, or</li>
1323     <li>
1324     <p>would change a relative path to an absolute path, or</li>
1325     <li>
1326     <p><code>p.empty()</code>, or</li>
1327     <li>
1328     <p><code>*p.native().cbegin()</code> is a directory separator.</li>
1329   </ul>
1330     <p>Then appends <code>p.native()</code> to <code>pathname</code>.</p>
1331   </blockquote>
1332   <p><i>Returns: </i><code>*this</code></p>
1333 </blockquote>
1334
1335 <pre>template &lt;class <a href="#Source">Source</a>&gt;
1336   path&amp; operator/=(Source const &amp; source);
1337   template &lt;class <a href="#Source">Source</a>&gt;
1338   path&amp; append(Source const &amp; source, const codecvt_type&amp; cvt);
1339   template &lt;class <a href="#InputIterator">InputIterator</a>&gt;
1340   path&amp; append(InputIterator begin, InputIterator end, const codecvt_type&amp; cvt=codecvt());</pre>
1341
1342 <blockquote>
1343   <p><i>Effects:</i></p>
1344   <blockquote>
1345     <p>Appends <code>path::preferred_separator</code> to <code>pathname</code>, converting
1346     format and encoding if required ([<a href="#path.arg.convert">path.arg.convert</a>]), unless:</p>
1347     <ul>
1348     <li>
1349     <p>an added separator
1350     would be redundant, or</li>
1351     <li>
1352     <p>would change a relative path to an absolute path, or</li>
1353     <li>
1354     <p><code>p.empty()</code>, or</li>
1355     <li>
1356     <p><code>*p.native().cbegin()</code> is a separator.</li>
1357   </ul>
1358     <p>Appends the contents [<code>begin</code>,<code>end</code>)
1359   or <code>source</code> to <code>pathname</code>, converting format and
1360     encoding if required ([<a href="#path.arg.convert">path.arg.convert</a>]).</p>
1361   </blockquote>
1362   <p><i>Returns: </i><code>*this</code></p>
1363   </blockquote>
1364
1365 <h3><a name="path-concatenation"><code>path</code> concatenation</a> [path.concat]</h3>
1366
1367 <pre>path&amp; operator+=(const path&amp; x);
1368 path&amp; operator+=(const string_type&amp; x);
1369 path&amp; operator+=(const value_type* x);
1370 path&amp; operator+=(value_type x);
1371 template &lt;class Source&gt;
1372   path&amp; operator+=(Source const&amp; x);
1373 template &lt;class CharT&gt;
1374   path&amp; operator+=(CharT x);
1375 template &lt;class InputIterator&gt;
1376   path&amp; concat(InputIterator begin, InputIterator end);
1377 template &lt;class InputIterator&gt;
1378   path&amp; concat(InputIterator begin, InputIterator end, const codecvt_type&amp; cvt);</pre>
1379
1380 <blockquote><p><i>Postcondition:</i> <code>native() == prior_native + <i>effective-argument</i></code>,
1381  where <code>prior_native</code> is <code>native()</code> prior to the call to <code>operator+=</code>,
1382  and <code><i>effective-argument</i></code> is:</p>
1383  <ul><li>
1384    <p><code>x.native()</code> if <code>x</code> is present and is <code>const path&amp;</code>, otherwise</li>
1385  <li>
1386  <p><code>s</code>, where <code>s</code> is
1387   <code>std::basic_string&lt;typename std::iterator_traits&lt;InputIterator&gt;::value_type&gt;<br>s(begin, end)</code>,
1388    if <code>begin</code> and <code>end</code> arguments are present, otherwise</li>
1389  <li>
1390  <p><code>x</code>.</li></ul><p>If the value type of <code><i>effective-argument</i></code> would not be <code>path::value_type</code>, the actual argument or argument range is first
1391    converted so that <code><i>effective-argument</i></code> has value type <code>path::value_type</code>.</li> </p>
1392  <p><i>Returns: </i><code>*this</code></p>
1393  </blockquote>
1394 <h3><a name="path-modifiers"> <code>
1395 path</code> modifiers</a> [path.modifiers]</h3>
1396
1397   <pre>void <a name="path-clear">clear</a>();</pre>
1398
1399 <blockquote>
1400 <p><i>Postcondition:</i> <code>this-&gt;empty()</code> is true.</p>
1401 </blockquote>
1402
1403 <pre>path&amp; <a name="path-make_preferred">make_preferred</a>();</pre>
1404
1405 <blockquote>
1406   <p><i>Effects:</i> <i>directory-separator</i>s are converted to <i>preferred-separator</i>s.
1407   See [<a href="#Operating-system-examples">fs.os.examples</a>].</p>
1408   <p><i>Returns:</i> <code>*this</code></p>
1409 </blockquote>
1410
1411
1412
1413 <pre>path&amp; <a name="path-remove_filename">remove_filename</a>();</pre>
1414
1415 <blockquote>
1416   <p><i>Returns: </i>As if, <code>*this = parent_path();</code></p>
1417   <p>[<i>Note:</i> This function is needed to efficiently implement <code>directory_iterator</code>. It is exposed to allow additional uses. The actual
1418   implementation may be much more efficient than <code>*this = parent_path()</code>&nbsp; <i>—end
1419   note</i>]</p>
1420 </blockquote>
1421
1422 <pre>path&amp; <a name="path-replace_extension">replace_extension</a>(const path&amp; new_extension = path());</pre>
1423
1424 <blockquote>
1425   <p><i>Effects:</i></p>
1426   <ul>
1427     <li>
1428     <p>Any existing <code>extension()</code> is removed from the stored path,
1429     then</li>
1430     <li>
1431     <p>iff
1432   <code>new_extension</code> is not empty and does not begin with a dot
1433     character, a dot character is appended to the stored path, then</li>
1434     <li>
1435   <p>
1436   <code>new_extension</code> is appended to the stored path.</li>
1437   </ul>
1438   <p><i>Returns:</i> <code>*this</code></p>
1439 </blockquote>
1440
1441 <pre><code>void <a name="path-swap">swap</a>(path&amp; rhs) noexcept;</code></pre>
1442
1443 <blockquote>
1444   <p><i>Effects:</i> Swaps the contents of the two paths.</p>
1445   <p><i>Complexity: </i>constant time.</p>
1446 </blockquote>
1447
1448   <h3><a name="path-lexical-operations"><code>path</code> lexical operations</a>
1449   [path.lex.ops]</h3>
1450   <pre>path <a name="lexically_normal">lexically_normal</a>() const;</pre>
1451 <blockquote>
1452 <p><i>Overview:</i> Returns <code>*this</code> with redundant current directory
1453 (<i>dot</i>), parent directory (<i>dot-dot</i>), and <i>directory-separator</i> elements removed.</p>
1454 <p><i>Returns:</i> <code>*this</code> in <a href="#normal-form">normal form</a>.</p>
1455 <p><i>Remarks:</i> Uses <code>operator/=</code> to compose the returned path.</p>
1456 <p>[<i>Example:</i></p>
1457 <p><code>assert(path(&quot;foo/./bar/..&quot;).lexically_normal() == &quot;foo&quot;);<br>
1458 assert(path(&quot;foo/.///bar/../&quot;).lexically_normal() == &quot;foo/.&quot;);</code></p>
1459 <p>The above assertions will succeed.<i> </i>On Windows, the
1460 returned path&#39;s <i>directory-separator</i> characters will be backslashes rather than slashes, but that
1461 does not affect <code>path</code> equality.<i> â€”end example</i>]</p>
1462 </blockquote>
1463
1464 <pre>path <a name="lexically_relative">lexically_relative</a>(const path&amp; base) const;</pre>
1465   <blockquote>
1466   <p><i>Overview:</i> Returns <code>*this</code> made relative to <code>base</code>.
1467   Treats empty or identical paths as corner cases, not errors. Does not resolve
1468   symlinks. Does not first normalize <code>*this</code> or <code>base</code>.</p>
1469
1470   <p><i>Remarks:</i> Uses <code>std::mismatch(begin(), end(), base.begin(), base.end())</code>, to determine the first mismatched element of
1471   <code>*this</code> and <code>base</code>. Uses <code>operator==</code> to
1472   determine if elements match. </p>
1473
1474   <p><i>Returns:</i> </p>
1475
1476   <ul>
1477     <li>
1478   <code>path()</code> if the first mismatched element of <code>*this</code> is equal to <code>
1479   begin()</code> or the first mismatched element
1480   of <code>base</code> is equal to <code>base.begin()</code>, or<br>&nbsp;
1481     </li>
1482     <li>
1483   <code>path(&quot;.&quot;)</code> if the first mismatched element of <code>
1484   *this</code> is equal to <code>
1485   end()</code> and the first mismatched element
1486   of <code>base</code> is equal to <code>base.end()</code>, or<br>&nbsp;
1487     </li>
1488     <li>An object of class <code>path</code> composed via application of <code>
1489     operator/= path(&quot;..&quot;)</code> for each element in the half-open
1490     range [first
1491     mismatched element of <code>base</code>, <code>base.end()</code>), and then
1492     application of <code>operator/=</code> for each element in the half-open
1493     range
1494     [first mismatched element of <code>*this</code>, <code>end()</code>).
1495     </li>
1496 </ul>
1497
1498 <p>[<i>Example:</i></p>
1499 <p><code>assert(path(&quot;/a/d&quot;).lexically_relative(&quot;/a/b/c&quot;) ==  &quot;../../d&quot;);<br>
1500 assert(path(&quot;/a/b/c&quot;).lexically_relative(&quot;/a/d&quot;) ==  &quot;../b/c&quot;);<br>
1501 assert(path(&quot;a/b/c&quot;).lexically_relative(&quot;a&quot;) == &quot;b/c&quot;);<br>
1502 assert(path(&quot;a/b/c&quot;).lexically_relative(&quot;a/b/c/x/y&quot;) ==  &quot;../..&quot;);<br>
1503 assert(path(&quot;a/b/c&quot;).lexically_relative(&quot;a/b/c&quot;) ==  &quot;.&quot;);<br>
1504 assert(path(&quot;a/b&quot;).lexically_relative(&quot;c/d&quot;) ==  &quot;&quot;);</code></p>
1505 <p>The above assertions will succeed.<i> </i>On Windows, the
1506 returned path&#39;s <i>directory-separator</i>s will be backslashes rather than
1507 forward slashes, but that
1508 does not affect <code>path</code> equality.<i> â€”end example</i>]</p>
1509
1510   <p>[<i>Note:</i> If symlink following semantics are desired, use the operational function <code>
1511   <a href="#op-relative">relative</a></code>&nbsp; <i>—end note</i>]</p>
1512
1513   <p>[<i>Note:</i> If <a href="#lexically_normal">normalization</a> is needed to ensure
1514   consistent matching of elements, apply <code><a href="#lexically_normal">lexically_normal()</a></code>
1515   to <code>*this</code>, <code>base</code>, or both. <i>—end note</i>]</p>
1516
1517 <pre>path <a name="lexically_proximate">lexically_proximate</a>(const path&amp; base) const;</pre>
1518 <blockquote>
1519 <p><i>Returns:</i> If <code>lexically_relative(base)</code> returns a non-empty path, returns that path.
1520 Otherwise returns <code>*this</code>.</p>
1521
1522   <p>[<i>Note:</i> If symlink following semantics are desired, use the operational function <code>
1523   <a href="#op-relative">relative</a></code>&nbsp; <i>—end note</i>]</p>
1524
1525   <p>[<i>Note:</i> If <a href="#lexically_normal">normalization</a> is needed to ensure
1526   consistent matching of elements, apply <code><a href="#lexically_normal">lexically_normal()</a></code>
1527   to <code>*this</code>, <code>base</code>, or both. <i>—end note</i>]</p>
1528
1529 </blockquote>
1530
1531
1532 <h3> <a name="path-native-format-observers"><code><font size="4">path</font></code> native format observers</a>
1533 [path.native.obs]</h3>
1534 <p>The string returned by all native format observers is in the <a href="#native-pathname-format">native pathname format</a>.</p>
1535
1536 <pre>const string_type&amp; <a name="native">native</a>() const noexcept;</pre>
1537
1538 <blockquote>
1539 <p><i>Returns:</i> <code>pathname</code>.</p>
1540 </blockquote>
1541
1542 <pre>const value_type* <a name="c_str">c_str</a>() const noexcept;</pre>
1543
1544 <blockquote>
1545 <p><i>Returns:</i> <code>pathname.c_str()</code>.</p>
1546 </blockquote>
1547
1548 <pre>string_type::size_type <a name="path-size">size</a>() const noexcept;</pre>
1549
1550 <blockquote>
1551 <p><i>Returns:</i> <code>pathname.size()</code>.</p>
1552 </blockquote>
1553
1554 <pre>template &lt;class String&gt;
1555 String <a name="string-template">string</a>(const codecvt_type&amp; cvt=codecvt()) const;</pre>
1556
1557 <blockquote>
1558   <p><i>Returns:</i> <code>pathname</code>.</p>
1559 <p><i>Remarks:</i> If <code>string_type</code> is a different type than <code>String</code>, conversion is performed by <code>cvt</code>.</p>
1560 </blockquote>
1561
1562 <pre>string <a name="string">string</a>(const codecvt_type&amp; cvt=codecvt()) const;
1563 wstring <a name="wstring">wstring</a>(const codecvt_type&amp; cvt=codecvt()) const;
1564 u16string <a name="u16string">u16string</a>() const;
1565 u32wstring <a name="u32wstring">u32wstring</a>() const; </pre>
1566
1567 <blockquote>
1568 <p><i>Returns:</i> <code>pathname</code>.</p>
1569 <p><i>Remarks:</i> If <code>string_type</code> is a different type than
1570 function's return type, conversion is performed by <code>cvt</code>.</p>
1571 </blockquote>
1572
1573 <h3> <a name="path-generic-format-observers"><code><font size="4">path</font></code> generic format observers</a>
1574 [path.generic.obs]</h3>
1575 <p>The string returned by all generic format observers is in the <a href="#generic-pathname-format">generic pathname format</a>.</p>
1576
1577 <pre>template &lt;class String&gt;
1578 String <a name="generic_string-template">generic_string</a>(const codecvt_type&amp; cvt=codecvt()) const;</pre>
1579
1580 <blockquote>
1581   <p><i>Returns:</i> <code>pathname</code>.</p>
1582 <p><i>Remarks:</i> If <code>string_type</code> is a different type than <code>String</code>, conversion is performed by <code>cvt</code>.</p>
1583 </blockquote>
1584
1585 <pre>string <a name="generic_string">generic_string</a>(const codecvt_type&amp; cvt=codecvt()) const;
1586 wstring <a name="generic_wstring">generic_wstring</a>(const codecvt_type&amp; cvt=codecvt()) const;
1587 u16string <a name="generic_u16string">generic_u16string</a>() const;
1588 u32wstring <a name="generic_u32wstring">generic_u32wstring</a>() const; </pre>
1589
1590 <blockquote>
1591 <p><i>Returns:</i> <code>pathname</code>.</p>
1592 <p><i>Remarks:</i>&nbsp; If <code>string_type</code> is a different type than
1593 function's return type, conversion is performed by <code>cvt</code>.</p>
1594 </blockquote>
1595
1596 <h3> <a name="path-compare"><code>path</code> compare</a> [path.compare]</h3>
1597
1598 <pre>int compare(const path&amp; p) const noexcept;</pre>
1599
1600 <blockquote>
1601   <p><i>Returns:</i> A value less than 0 if the elements of <code>*this</code> are lexicographically less than the elements of <code>p</code>, otherwise a
1602   value greater than 0 if the elements of <code>*this</code> are
1603   lexicographically greater than the elements of <code>p</code>, otherwise 0.</p>
1604   <p>Remark: The elements are determined as if by iteration over the half-open
1605   range [<code>begin()</code>, <code>end()</code>) for <code>*this</code> and&nbsp; <code>p</code>.</p>
1606 </blockquote>
1607
1608 <pre>int compare(const std::string&amp; s) const</pre>
1609
1610 <blockquote>
1611   <p><i>Returns:</i> <code>compare(path(s))</code>.</p>
1612 </blockquote>
1613
1614 <pre>int compare(const value_type* s) const</pre>
1615
1616 <blockquote>
1617   <p><i>Returns:</i> <code>compare(path(s))</code>.</p>
1618 </blockquote>
1619 <h3> <a name="path-decomposition"> <code><font size="4">path</font></code> decomposition</a>
1620 [path.decompose]</h3>
1621 <p><span style="background-color: #E0E0E0"><i>See the <a href="#path-decomposition-table">Path decomposition table</a> for examples
1622 for values returned by decomposition functions. The <a href="tutorial.html#Using-path-decomposition">Tutorial</a> may also be
1623 helpful.</i></span></p>
1624
1625 <pre>path <a name="path-root_name">root_name</a>() const;</pre>
1626
1627 <blockquote>
1628 <p><i>Returns:</i> <i>root-name,</i> if <code>pathname</code> includes <i>root-name</i>, otherwise <code>path()</code>. </p>
1629 </blockquote>
1630
1631 <pre>path <a name="path-root_directory">root_directory</a>() const;</pre>
1632
1633 <blockquote>
1634 <p><i>Returns:</i> <i>root-directory</i>, if <code>pathname</code> includes <i>root-directory</i>, otherwise <code>path()</code>.</p>
1635 <p>If <i>root-directory</i> is composed of <i>slash name</i>, <i>slash</i> is
1636 excluded from the returned string.</p>
1637 </blockquote>
1638
1639 <pre>path <a name="path-root_path">root_path</a>() const;</pre>
1640
1641 <blockquote>
1642   <p><i>Returns:</i> <code>root_name() / root_directory()</code></p>
1643 </blockquote>
1644
1645 <pre>path <a name="path-relative_path">relative_path</a>() const;</pre>
1646
1647 <blockquote>
1648 <p><i>Returns:</i> A <code>path</code> composed from <code>pathname</code>, if <code>!empty()</code>, beginning
1649 with the first <i>filename</i> after <i>root-path</i>. Otherwise, <code>path()</code>.</p>
1650 </blockquote>
1651
1652 <pre>path <a name="path-parent_path">parent_path</a>() const;</pre>
1653
1654 <blockquote>
1655   <p><i>Returns:</i> <code>(empty() || begin() == â€”end()) ? path() : <i>pp</i></code>, where <code><i>pp</i></code> is constructed as if by
1656   starting with an empty <code>path</code> and successively applying <code>operator/=</code> for each element in the range <code>begin()</code>, <code>—end()</code>.</p>
1657   <p>[<i>Example:</i></p>
1658   <blockquote>
1659
1660     <pre>std::cout &lt;&lt; path(&quot;/foo/bar.txt&quot;).parent_path(); // outputs &quot;/foo&quot;
1661 std::cout &lt;&lt; path(&quot;/foo/bar&quot;).parent_path();     // outputs &quot;/foo&quot;
1662 std::cout &lt;&lt; path(&quot;/foo/bar/&quot;).parent_path();    // outputs &quot;/foo/bar&quot;
1663 std::cout &lt;&lt; path(&quot;/&quot;).parent_path();            // outputs &quot;&quot;
1664 std::cout &lt;&lt; path(&quot;.&quot;).parent_path();            // outputs &quot;&quot;
1665 std::cout &lt;&lt; path(&quot;..&quot;).parent_path();           // outputs &quot;&quot;</pre>
1666
1667   </blockquote>
1668   <p> See the last bullet item in the <a href="#path-iterators">
1669   forward traversal order</a> list for why the <code>&quot;/foo/bar/&quot;</code> example
1670   doesn&#39;t output <code>&quot;/foo&quot;</code>.</p>
1671   <p> <i>—end example</i>]</p>
1672 </blockquote>
1673
1674 <pre>path <a name="path-filename">filename</a>() const;</pre>
1675
1676 <blockquote>
1677   <p><i>Returns:</i> <code>empty() ? path() : *—end()</code></p>
1678   <p>[<i>Example:</i></p>
1679   <blockquote>
1680
1681     <pre>std::cout &lt;&lt; path(&quot;/foo/bar.txt&quot;).filename(); // outputs &quot;bar.txt&quot;
1682 std::cout &lt;&lt; path(&quot;/foo/bar&quot;).filename();     // outputs &quot;bar&quot;
1683 std::cout &lt;&lt; path(&quot;/foo/bar/&quot;).filename();    // outputs &quot;.&quot;
1684 std::cout &lt;&lt; path(&quot;/&quot;).filename();            // outputs &quot;/&quot;
1685 std::cout &lt;&lt; path(&quot;.&quot;).filename();            // outputs &quot;.&quot;
1686 std::cout &lt;&lt; path(&quot;..&quot;).filename();           // outputs &quot;..&quot;</pre>
1687
1688   </blockquote>
1689   <p> See the last bullet item in the <a href="#path-iterators">
1690   forward traversal order</a> list for why the <code>&quot;/foo/bar/&quot;</code> example
1691   doesn&#39;t output <code>&quot;bar&quot;</code>.</p>
1692   <p> <i>—end example</i>]</p>
1693 </blockquote>
1694
1695 <pre>path <a name="path-stem">stem</a>() const;</pre>
1696
1697 <blockquote>
1698   <p><i>Returns:</i> if <code>p.filename()</code> contains a dot but does not
1699   consist solely of one or to two dots, returns
1700   the substring of <code>p.filename()</code> starting at its beginning and
1701   ending at the last dot (the dot is not included). Otherwise,
1702   returns <code>p.filename()</code>.</p>
1703   <p>[<i>Example:</i></p>
1704   <blockquote>
1705
1706     <pre><code>std::cout &lt;&lt; path(&quot;/foo/bar.txt&quot;).stem();</code> // outputs &quot;<code>bar</code>&quot;
1707 path p = &quot;foo.bar.baz.tar&quot;;
1708 for (; !p.extension().empty(); p = p.stem())
1709   std::cout &lt;&lt; p.extension() &lt;&lt; '\n';
1710   // outputs: .tar
1711   //          .baz
1712   //          .bar</pre>
1713
1714   </blockquote>
1715   <p> <i>—end example</i>]</p>
1716 </blockquote>
1717
1718 <pre>path <a name="path-extension">extension</a>() const;</pre>
1719
1720 <blockquote>
1721   <p><i>Returns:</i> if <code>p.filename()</code> contains a dot but does not
1722   consist solely of one or to two dots, returns
1723   the substring of <code>p.filename()</code> starting at the rightmost dot
1724   and ending at the path's end. Otherwise, returns an empty <code>path</code> object. </p>
1725   <p><i>Remarks:</i> Implementations are permitted but not required to define additional
1726   behavior for file systems which append additional elements to extensions, such
1727   as alternate data streams or partitioned dataset names.</p>
1728   <p>[<i>Example:</i></p>
1729   <blockquote>
1730
1731     <pre><code>std::cout &lt;&lt; path(&quot;/foo/bar.txt&quot;).extension(); //</code> outputs &quot;<code>.txt</code>&quot;</pre>
1732
1733   </blockquote>
1734   <p> <i>—end example</i>]</p>
1735   <p>[<i>Note:<b> </b></i>The dot is included in the return value so that it is
1736   possible to distinguish between no extension and an empty extension.
1737   See <a href="http://permalink.gmane.org/gmane.comp.lib.boost.devel/199744">
1738   http://permalink.gmane.org/gmane.comp.lib.boost.devel/199744</a> for more
1739   extensive rationale.&nbsp; <i>—end note</i>]</p>
1740 </blockquote>
1741 <h3> <a name="path-query"> <code><font size="4">path</font></code> query</a> [path.query]</h3>
1742
1743 <pre>bool <a name="path-empty">empty</a>() const;</pre>
1744
1745 <blockquote>
1746   <p><i>Returns:</i> <code>m_pathname.empty()</code>.</p>
1747 </blockquote>
1748
1749 <pre>bool <a name="filename_is_dot">filename_is_dot</a>() const;</pre>
1750
1751 <blockquote>
1752   <p><i>Returns:</i> <code>filename() == path(&quot;.&quot;)</code></p>
1753   <p>[<i>Example:</i></p>
1754   <blockquote>
1755
1756     <pre>std::cout &lt;&lt; path(&quot;.&quot;).filename_is_dot();     // outputs 1
1757 std::cout &lt;&lt; path(&quot;/.&quot;).filename_is_dot();    // outputs 1
1758 std::cout &lt;&lt; path(&quot;foo/.&quot;).filename_is_dot(); // outputs 1
1759 std::cout &lt;&lt; path(&quot;foo/&quot;).filename_is_dot();  // outputs 1
1760 std::cout &lt;&lt; path(&quot;/&quot;).filename_is_dot();     // outputs 0
1761 std::cout &lt;&lt; path(&quot;/foo&quot;).filename_is_dot();  // outputs 0
1762 std::cout &lt;&lt; path(&quot;/foo.&quot;).filename_is_dot(); // outputs 0
1763 std::cout &lt;&lt; path(&quot;..&quot;).filename_is_dot();    // outputs 0</pre>
1764
1765   </blockquote>
1766   <p> See the last bullet item in the <a href="#path-iterators">forward traversal order</a>
1767   list for why <code>path(&quot;foo/&quot;).filename()</code> is a dot filename.</p>
1768   <p> <i>—end example</i>]</p>
1769 </blockquote>
1770
1771 <pre>bool <a name="filename_is_dot_dot">filename_is_dot_dot</a>() const;</pre>
1772
1773 <blockquote>
1774   <p><i>Returns:</i> <code>filename() == path(&quot;..&quot;)</code></p>
1775 </blockquote>
1776
1777 <pre>bool <a name="path-has_root_path">has_root_path</a>() const;</pre>
1778
1779 <blockquote>
1780   <p><i>Returns:</i> <code>!<a href="#path-root_path">root_path</a>().empty()</code></p>
1781 </blockquote>
1782
1783 <pre>bool <a name="path-has_root_name">has_root_name</a>() const;</pre>
1784
1785 <blockquote>
1786   <p><i>Returns:</i> <code>!<a href="#path-root_name">root_name</a>().empty()</code></p>
1787 </blockquote>
1788
1789 <pre>bool <a name="path-has_root_directory">has_root_directory</a>() const;</pre>
1790
1791 <blockquote>
1792   <p><i>Returns:</i> <code>!<a href="#path-root_directory">root_directory</a>().empty()</code></p>
1793 </blockquote>
1794
1795 <pre>bool <a name="path-has_relative_path">has_relative_path</a>() const;</pre>
1796
1797 <blockquote>
1798   <p><i>Returns:</i> <code>!<a href="#path-has_relative_path">relative_path</a>().empty()</code></p>
1799 </blockquote>
1800
1801 <pre>bool <a name="path-has_parent_path">has_parent_path</a>() const;</pre>
1802
1803 <blockquote>
1804   <p><i>Returns:</i> <code>!<a href="#path-parent_path">parent_path</a>().empty()</code></p>
1805 </blockquote>
1806
1807 <pre>bool <a name="path-has_filename">has_filename</a>() const;</pre>
1808
1809 <blockquote>
1810   <p><i>Returns:</i> <code>!<a href="#path-filename">filename</a>().empty()</code></p>
1811 </blockquote>
1812
1813 <pre>bool <a name="path-has_stem">has_stem</a>() const;</pre>
1814
1815 <blockquote>
1816   <p><i>Returns:</i> <code>!<a href="#path-stem">stem</a>().empty()</code></p>
1817 </blockquote>
1818
1819 <pre>bool <a name="path-has_extension">has_extension</a>() const;</pre>
1820
1821 <blockquote>
1822   <p><i>Returns:</i> <code>!<a href="#path-has_extension">extension</a>().empty()</code></p>
1823 </blockquote>
1824
1825 <pre>bool <a name="path-is_absolute">is_absolute</a>() const;</pre>
1826
1827 <blockquote>
1828   <p><i>Returns:</i> <code>true</code> if the elements of <code>root_path()</code> uniquely identify a directory, else <code>false</code>.</p>
1829 </blockquote>
1830
1831 <pre>bool <a name="path-is_relative">is_relative</a>() const;</pre>
1832
1833 <blockquote>
1834   <p><i>Returns:</i> <code>!is_absolute()</code>.</p>
1835 </blockquote>
1836 <h3> <a name="path-iterators"> <code>
1837 <font size="4">path</font></code> iterators</a> [path.itr]</h3>
1838 <p> Path iterators <code>iterator</code>, <code>const_iterator</code>,
1839 <code>reverse_iterator</code>, and <code>const_reverse_iterator</code> iterate over the elements of the stored pathname.</p>
1840 <p> Path iterators are constant iterators satisfying
1841 the requirements of a bidirectional iterator (C++ Std, 24.1.4 Bidirectional
1842 iterators [lib.bidirectional.iterators]). The <code>value_type</code>&nbsp; of
1843 an iterator is <code>path</code>.</p>
1844   <blockquote>
1845 <p> [<i>Note:</i> Path iterators store their value objects internally
1846 and when dereferenced return references to those internal objects. They cannot
1847 be used with iterator adaptors such as <code>std::reverse_iterator</code> that
1848 assume references obtained by dereferencing an iterator point to objects that
1849 out-live the iterator itself. <i>—end note</i>] </p>
1850 </blockquote>
1851   <p>Calling any non-const member function of a <code>path</code> object
1852   invalidates all iterators referring to elements of that object.</p>
1853 <p> The forward traversal order is as follows:</p>
1854 <ul>
1855   <li>The <i>root-name</i> element, if present.</li>
1856   <li>The <i>root-directory</i> element, if present, in the generic format. <i>
1857   [note:</i> the generic format is required to ensure lexicographical
1858   comparison works correctly. <i>—end note</i>]</li>
1859   <li>Each successive <i>filename</i> element, if present.</li>
1860   <li><i>Dot</i>, if one or more trailing non-root <i>slash</i>
1861   characters are present.|</li>
1862 </ul>
1863   <blockquote>
1864   <p>[<i>Note:</i> Treating the last element during iteration as <i>dot</i> when
1865   there is a trailing directory separator enables lexical (i.e. syntactic)
1866   distinction between paths to directories versus paths to regular files. Such a
1867   distinction is usually irrelevant on POSIX and Windows based operating
1868   systems, but may be a requirement on other operating systems. <i>—end note</i>]</p>
1869   </blockquote>
1870   <p>The backward traversal order is the reverse of forward traversal.</p>
1871   <pre>iterator begin() const;</pre>
1872 <blockquote>
1873   <p><i>Returns:</i> An iterator for the first  element in forward traversal
1874   order. If no elements are present, the end iterator.</p>
1875 </blockquote>
1876 <pre>iterator end() const;</pre>
1877 <blockquote>
1878   <p><i>Returns:</i> The end iterator.</p>
1879 </blockquote>
1880   <pre>reverse_iterator rbegin() const;</pre>
1881 <blockquote>
1882   <p><i>Returns:</i> An iterator for the first element in backward traversal
1883   order. If no elements are present, the end iterator.</p>
1884 </blockquote>
1885 <pre>reverse_iterator rend() const;</pre>
1886 <blockquote>
1887   <p><i>Returns:</i> The end iterator.</p>
1888 </blockquote>
1889  <h3><a name="path-imbued-locale"><code><font size="4"> path</font></code>
1890  imbued locale</a> [path.imbued.locale]</h3>
1891  <p><code>path</code> operations sometimes require encoding conversions between
1892  <code>pathname</code> and some other string object where one of the value types
1893  is <code>char</code> and the other is <code>wchar_t</code>. Such conversions
1894  shall be performed by the <code>path::codecvt()</code> facet.</p>
1895  <blockquote>
1896  <p><span style="background-color: #FFFF00">[</span><i><span style="background-color: #FFFF00">Example:</span></i><span style="background-color: #FFFF00">
1897  ... </span><i><span style="background-color: #FFFF00">—end example</span></i><span style="background-color: #FFFF00">]</span></p>
1898  </blockquote>
1899  <pre>static std::locale <a name="path-imbue">imbue</a>(const std::locale&amp; loc);</pre>
1900 <blockquote>
1901   <p><i>Effects:</i> Stores a copy of <code>loc</code> as the imbued <code>path</code>
1902   locale.</p>
1903   <p><i>Returns:</i> The previous imbued <code>path</code> locale.</p>
1904   <p><i>Remarks:</i> The initial value of the imbued <code>path</code> locale is
1905   operating system dependent. It shall be a locale with a <code>codecvt</code>
1906   facet for a <code>char</code> string encoding appropriate for the operating
1907   system. See ([<a href="#Operating-system-examples">fs.os.examples</a>]).&nbsp; </p>
1908 </blockquote>
1909 <pre>static const codecvt_type&amp; <a name="path-codecvt">codecvt</a>();</pre>
1910 <blockquote>
1911   <p><i>Returns:</i> The <code>codecvt</code> facet for the imbued<code> path</code>
1912   locale .</p>
1913 </blockquote>
1914
1915
1916 <h3> <a name="path-deprecated-functions"><code><font size="4"> path</font></code> deprecated functions</a></h3>
1917 <p> Several member functions from previous versions of <code>class path</code> have been deprecated, either because they have been renamed or because the
1918 functionality is no longer desirable or has become obsolete.</p>
1919 <p> Deprecated functions available by default; will be suppressed if <code>BOOST_FILESYSTEM_NO_DEPRECATED</code> is defined:</p>
1920 <blockquote>
1921   <pre>path&amp;  remove_leaf()           { return remove_filename(); }
1922 path   leaf() const            { return filename(); }
1923 path   branch_path() const     { return parent_path(); }
1924 bool   has_leaf() const        { return !m_path.empty(); }
1925 bool   has_branch_path() const { return !parent_path().empty(); }</pre>
1926 </blockquote>
1927 <p> Deprecated functions not available by default; will be supplied if <code>BOOST_FILESYSTEM_DEPRECATED</code> is defined:</p>
1928 <blockquote>
1929 <pre>const std::string  file_string() const               { return native_string(); }
1930 const std::string  directory_string() const          { return native_string(); }
1931 const std::string  native_file_string() const        { return native_string(); }
1932 const std::string  native_directory_string() const   { return native_string(); }
1933 const string_type  external_file_string() const      { return native(); }
1934 const string_type  external_directory_string() const { return native(); }</pre>
1935 </blockquote>
1936
1937 <h3> <a name="path-non-member-functions"> <code><font size="4">path</font></code> non-member functions</a>
1938 [path.non-member]</h3>
1939
1940   <pre>bool lexicographical_compare(path::iterator first1, path::iterator last1,
1941                              path::iterator first2, path::iterator last2);</pre>
1942 <blockquote>
1943   <p><i>Returns:</i> <code>true</code> if the sequence of <code>native()</code> strings for the elements defined by the half-open range <code>[first1,last1)</code> is
1944   lexicographically less than the sequence of <code>native()</code> strings for
1945   the elements defined by the half-open range <code>[first2,last2)</code>. Returns <code>false</code> otherwise.</p>
1946   <p><i>Remarks:</i> If two sequences have the same number of elements and their
1947   corresponding elements are equivalent, then neither sequence is
1948   lexicographically less than the other. If one sequence is a prefix of the
1949   other, then the shorter sequence is lexicographically less than the longer
1950   sequence. Otherwise, the lexicographical comparison of the sequences yields
1951   the same result as the comparison of the first corresponding pair of elements
1952   that are not equivalent.</p>
1953   <p>[<i>Note:</i> A <code>path</code> aware <code>lexicographical_compare</code> algorithm is provided for historical reasons. <i>—end note</i>]</p>
1954 </blockquote>
1955
1956   <div>
1957
1958   <pre>path <a name="lex-normal">lexically_normal</a>(const path&amp; p);</pre>
1959
1960   </div>
1961
1962 <blockquote>
1963   <p><i>Overview:</i> Returns <code>p</code> with redundant current
1964   directory (<i>dot</i>), parent directory (<i>dot-dot</i>), and <i>
1965   directory-separator</i> elements removed.</p>
1966   <p><i>Returns:</i> <code>p</code> in
1967   <a href="#normal-form">
1968   normal form</a>.</p>
1969   <p><i>Remarks:</i> Uses <code>operator/=</code> to compose the
1970   returned path.</p>
1971   <p>[<i>Example:</i></p>
1972   <p><code>assert(lexically_normal(&quot;foo/./bar/..&quot;) == &quot;foo&quot;);<br>
1973   assert(lexically_normal(&quot;foo/.///bar/../&quot;) == &quot;foo/.&quot;);</code></p>
1974   <p>All of the above assertions will succeed.<i> </i>On Windows, the
1975   returned path&#39;s <i>directory-separator</i> characters will be backslashes
1976   rather than slashes, but that does not affect <code>path</code> equality.<i>
1977   â€”end example</i>]</p>
1978 </blockquote>
1979
1980   <div>
1981
1982   <pre>path lexically_<a name="lex-relative">relative</a>(const path&amp; p, const path&amp; base);</pre>
1983
1984   </div>
1985
1986 <blockquote>
1987   <p><i>Overview:</i> Returns <code>p</code> made relative to <code>
1988   base</code>. Treats empty or identical paths as corner cases, not errors. Does
1989   not resolve symlinks. Does not first normalize <code>p</code> or <code>base</code>.</p>
1990   <p><i>Remarks:</i> Uses <code>std::mismatch(p.begin(), p.end(),
1991   base.begin(), base.end())</code>, to determine the first mismatched element of
1992   <code>p</code> and <code>base</code>. Uses <code>operator==</code> to
1993   determine if elements match. </p>
1994   <p><i>Returns:</i> </p>
1995   <ul>
1996     <li>
1997     <p><code>path()</code> if the first mismatched element of <code>p</code>
1998     is equal to <code>p.begin()</code> or the first mismatched element of <code>
1999     base</code> is equal to <code>base.begin()</code>, or<br>
2000     &nbsp; </li>
2001     <li>
2002     <p><code>path(&quot;.&quot;)</code> if the first mismatched element of <code>
2003     p</code> is equal to <code>p.end()</code> and the first mismatched element
2004     of <code>base</code> is equal to <code>base.end()</code>, or<br>
2005     &nbsp; </li>
2006     <li>
2007     <p>An object of class <code>path</code> composed via application
2008     of <code>operator/= path(&quot;..&quot;)</code> for each element in the half-open
2009     range [first mismatched element of <code>base</code>, <code>base.end()</code>),
2010     and then application of <code>operator/=</code> for each element in the
2011     half-open range [first mismatched element of <code>p</code>, <code>p.end()</code>).
2012     </li>
2013   </ul>
2014   <p>[<i>Example:</i></p>
2015   <p><code>assert(lexically_relative(&quot;/a/d&quot;, &quot;/a/b/c&quot;) == &quot;../../d&quot;);<br>
2016   assert(lexically_relative(&quot;/a/b/c&quot;, &quot;/a/d&quot;) == &quot;../b/c&quot;);<br>
2017   assert(lexically_relative(&quot;a/b/c&quot;, &quot;a&quot;) == &quot;b/c&quot;);<br>
2018   assert(lexically_relative(&quot;a/b/c&quot;, &quot;a/b/c/x/y&quot;) == &quot;../..&quot;);<br>
2019   assert(lexically_relative(&quot;a/b/c&quot;, &quot;a/b/c&quot;) == &quot;.&quot;);<br>
2020   assert(lexically_relative(&quot;a/b&quot;, &quot;c/d&quot;) == &quot;&quot;);</code></p>
2021   <p>All of the above assertions will succeed.<i> </i>On Windows, the
2022   returned path&#39;s <i>directory-separator</i>s will be backslashes rather than
2023   forward slashes, but that does not affect <code>path</code> equality.<i> â€”end
2024   example</i>]</p>
2025   <p>[<i>Note:</i> If symlink following semantics are desired, use the
2026   operational function <code>
2027   <a href="#op-relative">
2028   relative</a></code>&nbsp; <i>—end note</i>]</p>
2029   <p>[<i>Note:</i> If <a href="#normal-form">normalization</a> is needed to ensure consistent matching of elements, wrap
2030   <code>p</code>, <code>base</code>, or both in calls <code>
2031   <a href="#lex-normal">
2032   lexically_normal()</a></code>. <i>—end note</i>]</p>
2033 </blockquote>
2034 <pre>void swap( path&amp; lhs, path&amp; rhs )</pre>
2035 <blockquote>
2036   <p><i>Effects: </i><code>lhs.swap(rhs)</code>.</p>
2037 </blockquote>
2038 <pre>std::size_t <a name="hash_value">hash_value</a> (const path&amp; p);</pre>
2039 <blockquote>
2040   <p><i>Returns:</i> A hash value for the path <code>p</code>. If
2041   for two paths, <code>p1 == p2</code> then <code>hash_value(p1) == hash_value(p2)</code>.</p>
2042   <p>This allows paths to be used with <a href="../../functional/hash/index.html">Boost.Hash</a>.</p>
2043 </blockquote>
2044 <pre>bool operator&lt; (const path&amp; lhs, const path&amp; rhs);</pre>
2045 <blockquote>
2046   <p><i>Returns:</i> <code>return lhs.compare(rhs.begin) &lt; 0</code>.</p>
2047 </blockquote>
2048 <pre>bool operator&lt;=(const path&amp; lhs, const path&amp; rhs);</pre>
2049 <blockquote>
2050   <p><i>Returns:</i> <code>!(rhs &lt; lhs)</code>.</p>
2051 </blockquote>
2052 <pre>bool operator&gt; (const path&amp; lhs, const path&amp; rhs);</pre>
2053 <blockquote>
2054   <p><i>Returns:</i> <code>rhs &lt; lhs</code>.</p>
2055 </blockquote>
2056 <pre>bool operator&gt;=(const path&amp; lhs, const path&amp; rhs);</pre>
2057 <blockquote>
2058   <p><i>Returns:</i> <code>!(lhs &lt; rhs)</code>.</p>
2059 </blockquote>
2060 <pre>bool operator==(const path&amp; lhs, const path&amp; rhs);</pre>
2061 <blockquote>
2062   <p><i>Returns:</i> <code>!(lhs &lt; rhs) &amp;&amp; !(rhs &lt; lhs)</code>.</p>
2063   <p>[<i>Note:</i> <a name="Path-equality">Path equality</a> and path
2064   equivalence have different semantics.</p>
2065   <p>Equality is determined by the <code>path</code> non-member <code>operator==</code>, which considers the two path's lexical
2066   representations only. Thus <code>path(&quot;foo&quot;) == &quot;bar&quot;</code> is never <code>true</code>.</p>
2067   <p>Equivalence is determined by the <a href="#equivalent"><code>equivalent()</code></a> non-member function, which determines if two paths <a href="#path">resolve</a> to the same file system entity.
2068   Thus <code>equivalent(&quot;foo&quot;, &quot;bar&quot;)</code> will be <code>true</code> when both paths resolve to the same file.</p>
2069   <p>Programmers wishing to determine if two paths are &quot;the same&quot; must decide if
2070   &quot;the same&quot; means &quot;the same representation&quot; or &quot;resolve to the same actual
2071   file&quot;, and choose the appropriate function accordingly. <i>—end note</i>]</p>
2072 </blockquote>
2073 <pre>bool operator!=(const path&amp; lhs, const path&amp; rhs);</pre>
2074 <blockquote>
2075   <p><i>Returns:</i> <code>!(lhs == rhs)</code>.</p>
2076 </blockquote>
2077 <pre>path operator/ (const path&amp; lhs, const path&amp; rhs);</pre>
2078 <blockquote>
2079   <p><i>Returns:</i> <code>path(lhs) /= rhs</code>.</p>
2080 </blockquote>
2081 <h3> <a name="path-non-member-operators"><code><font size="4">path</font></code></a><a name="path-inserter-extractor"> inserter
2082   and extractor</a> [path.io]</h3>
2083 <p> The inserter and extractor delimit the string with double-quotes (<code>&quot;</code>)
2084 so that paths with embedded spaces will round trip correctly. Ampersand (<code>&amp;</code>)
2085 is as an escape character, so the path can itself contain double quotes.</p>
2086 <pre>template &lt;class Char, class Traits&gt;
2087 std::basic_ostream&lt;Char, Traits&gt;&amp; operator&lt;&lt;(std::basic_ostream&lt;Char, Traits&gt;&amp; os,
2088                                              const path&amp; p)
2089 </pre>
2090 <blockquote>
2091   <p><i>Effects: </i>Insert characters into <code>os</code>:</p>
2092   <ul>
2093     <li>
2094   <p>A double-quote.</p>
2095     </li>
2096     <li>
2097   <p>Each character in <code>p.string&lt;std::basic_string&lt;Char&gt;&gt;()</code>.
2098   If the character to be inserted is equal to the escape character or a
2099   double-quote, as determined by <code>operator==</code>, first insert the
2100   escape character.</p>
2101     </li>
2102     <li>
2103   <p>A double-quote.</p>
2104     </li>
2105   </ul>
2106   <p><i>Returns:</i> <code>os</code></p>
2107 </blockquote>
2108 <pre>template &lt;class Char, class Traits&gt;
2109 inline std::basic_istream&lt;Char, Traits&gt;&amp; operator&gt;&gt;(std::basic_istream&lt;Char, Traits&gt;&amp; is,
2110                                                     path&amp; p)
2111 </pre>
2112 <blockquote>
2113   <p><i>Effects:&nbsp; </i><code>&nbsp;std::basic_string&lt;Char&gt; str;<br>
2114 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is &gt;&gt; <a href="../../io/doc/quoted_manip.html">boost::io::quoted</a>(str, static_cast&lt;Char&gt;('&amp;'));<br>
2115 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p = str;</code></p>
2116   <p><i>Effects:&nbsp; </i>Extract characters from os:</p>
2117   <ul>
2118     <li>If the first character that would be extracted is equal to double-quote,
2119     as determined by <code>operator==</code>, then:<ul>
2120       <li>Discard the initial double-quote.</li>
2121       <li>Save the value and then turn off the <code>skipws</code> flag.</li>
2122       <li><code>p.clear()</code></li>
2123       <li>Until an unescaped double-quote character is reached or <code>
2124       is.not_good()</code>, extract characters from <code>os</code> and append
2125       them to <code>p</code>, except that if an escape character is reached,
2126       ignore it and append the next character to <code>p</code>.</li>
2127       <li>Discard the final double-quote character.</li>
2128       <li>Restore the <code>skipws</code> flag to its original value.</li>
2129     </ul>
2130     </li>
2131     <li>Otherwise, <code>os &gt;&gt; p</code>.</li>
2132   </ul>
2133   <p><i>Returns:</i> <code>is</code></p>
2134   </blockquote>
2135 <h2><a name="Class-filesystem_error">Class <code>filesystem_error</code>
2136 [class.filesystem_error]</a></h2>
2137 <pre>namespace boost
2138 {
2139   namespace filesystem
2140   {
2141       class filesystem_error : public system_error
2142       {
2143       public:
2144         filesystem_error();
2145         filesystem_error(const filesystem_error&amp;);
2146         <a href="#filesystem_error-2-arg">filesystem_error</a>(const std::string&amp; what_arg,
2147           system::error_code ec);
2148         <a href="#filesystem_error-3-arg">filesystem_error</a>(const std::string&amp; what_arg,
2149           const path&amp; p1, system::error_code ec);
2150         <a href="#filesystem_error-4-arg">filesystem_error</a>(const std::string&amp; what_arg,
2151           const path&amp; p1, const path&amp; p2, system::error_code ec);
2152
2153         filesystem_error&amp; filesystem_error(const filesystem_error&amp;);
2154        ~filesystem_error();
2155
2156         filesystem_error&amp; operator=(const filesystem_error&amp;);
2157
2158         const path&amp; <a href="#filesystem_error-path1">path1</a>() const;
2159         const path&amp; <a href="#filesystem_error-path2">path2</a>() const;
2160
2161         const char * <a href="#filesystem_error-what">what</a>() const;
2162       };
2163   }  // namespace filesystem
2164 }  // namespace boost</pre>
2165 <p>The class template <code>filesystem_error</code> defines the type of
2166 objects thrown as exceptions to report file system errors from functions described in this
2167 reference documentation.</p>
2168 <h3> <a name="filesystem_error-members"> <code>filesystem_error</code> members</a>
2169 [filesystem_error.members]</h3>
2170 <pre><a name="filesystem_error-2-arg">filesystem_error</a>(const std::string&amp; what_arg, error_code ec);</pre>
2171 <blockquote>
2172   <p><i>Postcondition:</i></p>
2173   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="46%">
2174     <tr>
2175       <td width="18%"><b>Expression</b></td>
2176       <td width="82%"><b>Value</b></td>
2177     </tr>
2178     <tr>
2179       <td width="18%" bgcolor="#FFFFFF"><code>
2180       runtime_error::what()</code></td>
2181       <td width="82%" bgcolor="#FFFFFF">
2182       <code><i>what_arg</i>.c_str()</code></td>
2183     </tr>
2184     <tr>
2185       <td width="18%"><code>code()</code></td>
2186       <td width="82%"><code>ec</code></td>
2187     </tr>
2188     <tr>
2189       <td width="18%"><code>path1().empty()</code></td>
2190       <td width="82%"><code>true</code></td>
2191     </tr>
2192     <tr>
2193       <td width="18%"><code>path2().empty()</code></td>
2194       <td width="82%"><code>true</code></td>
2195     </tr>
2196   </table>
2197 </blockquote>
2198 <pre><a name="filesystem_error-3-arg">filesystem_error</a>(const std::string&amp; what_arg, const path&amp; p1, error_code ec);</pre>
2199 <blockquote>
2200   <p><i>Postcondition:</i></p>
2201   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="46%">
2202     <tr>
2203       <td width="18%"><b>Expression</b></td>
2204       <td width="82%"><b>Value</b></td>
2205     </tr>
2206     <tr>
2207       <td width="18%" valign="top"><code>
2208       runtime_error::what()</code></td>
2209       <td width="82%">
2210       <code><i>what_arg</i>.c_str()</code></td>
2211     </tr>
2212     <tr>
2213       <td width="18%" valign="top"><code>code()</code></td>
2214       <td width="82%"><code>ec</code></td>
2215     </tr>
2216     <tr>
2217       <td width="18%" valign="top"><code>path1()</code></td>
2218       <td width="82%">Reference to stored copy of <code>p1</code></td>
2219     </tr>
2220     <tr>
2221       <td width="18%" valign="top"><code>path2().empty()</code></td>
2222       <td width="82%"><code>true</code></td>
2223     </tr>
2224   </table>
2225 </blockquote>
2226 <pre><a name="filesystem_error-4-arg">filesystem_error</a>(const std::string&amp; what_arg, const path&amp; p1, const path&amp; p2, error_code ec);</pre>
2227 <blockquote>
2228   <p><i>Postcondition:</i></p>
2229   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="46%">
2230     <tr>
2231       <td width="18%"><b>Expression</b></td>
2232       <td width="82%"><b>Value</b></td>
2233     </tr>
2234     <tr>
2235       <td width="18%"><code>
2236       runtime_error::what()</code></td>
2237       <td width="82%">
2238       <u>
2239       <code><i>w</i></code></u><code><i>hat_arg</i>.c_str()</code></td>
2240     </tr>
2241     <tr>
2242       <td width="18%"><code>code()</code></td>
2243       <td width="82%"><code>ec</code></td>
2244     </tr>
2245     <tr>
2246       <td width="18%"><code>path1()</code></td>
2247       <td width="82%">Reference to stored copy of <code>p1</code></td>
2248     </tr>
2249     <tr>
2250       <td width="18%"><code>path2()</code></td>
2251       <td width="82%">Reference to stored copy of <code>p2</code></td>
2252     </tr>
2253   </table>
2254 </blockquote>
2255 <pre>const path&amp; <a name="filesystem_error-path1">path1</a>() const;</pre>
2256 <blockquote>
2257   <p><i>Returns:</i> Reference to copy of <code>p1</code> stored by the
2258   constructor, or, if none, an empty path.</p>
2259 </blockquote>
2260 <pre>const path&amp; <a name="filesystem_error-path2">path2</a>() const;</pre>
2261 <blockquote>
2262   <p><i>Returns:</i> Reference to copy of <code>p2</code> stored by the
2263   constructor, or, if none, an empty path.</p>
2264 </blockquote>
2265 <pre>const char* <a name="filesystem_error-what">what</a>() const;</pre>
2266 <blockquote>
2267   <p><i>Returns: </i>A string containing <code>runtime_error::what()</code>. The exact format is unspecified.
2268   Implementations are encouraged but not required to include <code>path1.native_string()</code>if not empty, <code>path2.native_string()</code>if
2269   not empty, and <code>system_error::what()</code> strings in the returned
2270   string.</p>
2271 </blockquote>
2272 <h2><a name="Enum-file_type">Enum file_type</a> [enum.file_type]</h2>
2273 <p>This enum specifies constants uses to identify file types.</p>
2274 <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
2275   <tr>
2276     <td><b>Constant Name</b></td>
2277     <td><b>Meaning</b></td>
2278   </tr>
2279   <tr>
2280     <td><code>status_error</code></td>
2281     <td>An error occurred while trying to obtain the status of the file. The
2282     file simply not being found is <b><u>not</u></b> considered a status error. </td>
2283   </tr>
2284   <tr>
2285     <td><code>file_not_found</code></td>
2286     <td>The file could not be found</td>
2287   </tr>
2288   <tr>
2289     <td><code>regular_file</code></td>
2290     <td>Regular file</td>
2291   </tr>
2292   <tr>
2293     <td><code>directory_file</code></td>
2294     <td>Directory file</td>
2295   </tr>
2296   <tr>
2297     <td><code>symlink_file</code></td>
2298     <td>Symbolic link file</td>
2299   </tr>
2300   <tr>
2301     <td><code>block_file</code></td>
2302     <td>Block special file</td>
2303   </tr>
2304   <tr>
2305     <td><code>character_file</code></td>
2306     <td>Character special file</td>
2307   </tr>
2308   <tr>
2309     <td><code>fifo_file</code></td>
2310     <td>FIFO or pipe file</td>
2311   </tr>
2312   <tr>
2313     <td><code>socket_file</code></td>
2314     <td>Socket file</td>
2315   </tr>
2316   <tr>
2317     <td><code>type_unknown</code></td>
2318     <td>The file exists, but it is of a system specific type not covered by any
2319     of the above cases.</td>
2320   </tr>
2321 </table>
2322 <h2><a name="Enum-perms">Enum perms</a> [enum.perms]</h2>
2323 <p>This <code>enum</code> specifies bitmask constants uses to identify file
2324 permissions. <i><span style="background-color: #E0E0E0">ISO/</span><span style="background-color: #E0E0E0">IEC</span><span style="background-color: #E0E0E0"> 9945
2325 (POSIX) specifies actual values, and those values have been adopted here because
2326 they are very familiar and ingrained for many POSIX
2327 users.</span></i></p>
2328 <blockquote>
2329 <p><span style="background-color: #FFFF00">Windows: All permissions except write are currently ignored. There is only a
2330 single write permission; setting write permission for owner, group, or others
2331 sets write permission for all, and removing write permission for owner, group,
2332 or others removes write permission for all. </span> </p>
2333 </blockquote>
2334 <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
2335   <tr>
2336     <td><b>Name</b></td>
2337     <td align="center"><b>Value<br>
2338     (octal)</b></td>
2339     <td align="center"><b>ISO/IEC 9945<br>
2340     macro</b></td>
2341     <td><b>Definition or notes</b></td>
2342   </tr>
2343
2344 <tr><td>
2345   <p><code>no_perms</code></td><td><code>0</code></td><td></td>
2346   <td>There are no permissions set for the file. Note: <code>file_not_found</code> is <code>no_perms</code> rather than <code>perms_not_known</code></td>
2347 </tr>
2348 <tr><td><code>owner_read</code></td><td><code>0400</code></td><td> <code>S_IRUSR</code></td>
2349   <td> Read permission, owner</td>
2350 </tr>
2351 <tr><td><code>owner_write</code></td><td><code>0200</code></td><td> <code>S_IWUSR</code></td>
2352   <td> Write permission, owner</td>
2353 </tr>
2354 <tr><td><code>owner_exe</code></td><td><code>0100</code></td><td>  <code>S_IXUSR</code></td>
2355   <td> Execute/search permission, owner</td>
2356 </tr>
2357 <tr><td><code>owner_all</code></td><td><code>0700</code></td><td>  <code>S_IRWXU</code></td>
2358   <td> Read, write, execute/search by owner; <code>owner_read | owner_write | owner_exe</code></td>
2359 </tr>
2360 <tr><td><code>group_read</code></td><td><code>040</code></td><td>  <code>S_IRGRP</code></td>
2361   <td> Read permission, group</td>
2362 </tr>
2363 <tr><td><code>group_write</code></td><td><code>020</code></td><td> <code>S_IWGRP</code></td>
2364   <td> Write permission, group</td>
2365 </tr>
2366 <tr><td><code>group_exe</code></td><td><code>010</code></td><td>   <code>S_IXGRP</code></td>
2367   <td> Execute/search permission, group</td>
2368 </tr>
2369 <tr><td><code>group_all</code></td><td><code>070</code></td><td>   <code>S_IRWXG</code></td>
2370   <td> Read, write, execute/search by group; <code>group_read | group_write | group_exe</code></td>
2371 </tr>
2372 <tr><td><code>others_read</code></td><td><code>04</code></td><td>  <code>S_IROTH</code></td>
2373   <td> Read permission, others</td>
2374 </tr>
2375 <tr><td><code>others_write</code></td><td><code>02</code></td><td> <code>S_IWOTH</code></td>
2376   <td> Write permission, others</td>
2377 </tr>
2378 <tr><td><code>others_exe</code></td><td><code>01</code></td><td>   <code>S_IXOTH</code></td>
2379   <td> Execute/search permission, others</td>
2380 </tr>
2381 <tr><td><code>others_all</code></td><td><code>07</code></td><td>   <code>S_IRWXO</code></td>
2382   <td>Read, write, execute/search by others; <code>others_read | others_write | others_exe</code></td>
2383 </tr>
2384 <tr><td><code>all_all</code></td><td><code>0777</code></td><td> </td><td><code>owner_all | group_all | others_all</code></td>
2385 </tr>
2386 <tr><td><code>set_uid_on_exe</code></td><td><code>04000</code></td><td> <code>S_ISUID</code></td>
2387   <td> Set-user-ID on execution</td>
2388 </tr>
2389 <tr><td><code>set_gid_on_exe</code></td><td><code>02000</code></td><td> <code>S_ISGID</code></td>
2390   <td> Set-group-ID on execution</td>
2391 </tr>
2392 <tr><td><code><a name="sticky_bit">sticky_bit</a> </code></td><td><code>01000</code></td><td> <code>S_ISVTX</code></td>
2393   <td> Operating system dependent. Inherently non-portable, even between ISO/IEC 9945
2394   operating systems.</td>
2395 </tr>
2396 <tr><td><code><a name="perms_mask">perms_mask</a></code></td><td><code>07777</code></td><td> &nbsp;</td>
2397   <td><code>all_all | set_uid_on_exe | set_gid_on_exe | sticky_bit</code></td>
2398 </tr>
2399 <tr><td><code>perms_not_known</code></td><td><code>0xFFFF</code></td><td></td><td>
2400   The permissions are not known, such as when a <code>file_status</code> object
2401   is created without specifying the permissions</td>
2402 </tr>
2403 <tr><td>
2404   <p><code>add_perms</code></td><td><code>0x1000</code></td><td></td><td>
2405   <p><code>permissions()</code> adds the argument permission bits to the
2406   file's current bits</td>
2407 </tr>
2408 <tr><td><code>remove_perms</code></td><td><code>0x2000</code></td><td></td><td>
2409   <code>permissions()</code> removes the argument permission bits from the
2410   file's current bits</td>
2411 </tr>
2412 <tr><td><code><a name="symlink_perms">symlink_perms</a></code></td><td><code>0x4000</code></td><td></td><td>
2413   <span style="background-color: #FFFF00">On ISO/</span><span style="background-color: #FFFF00">IEC</span><span style="background-color: #FFFF00"> 9945
2414   </span> <code><span style="background-color: #FFFF00">permissions()</span></code><span style="background-color: #FFFF00"> resolves symlinks unless
2415   </span> <code><span style="background-color: #FFFF00">symlink_perms</span></code><span style="background-color: #FFFF00"> is specified.
2416   Meaningless on Windows as </span> <code>
2417   <span style="background-color: #FFFF00">permissions()</span></code><span style="background-color: #FFFF00"> never resolves symlinks.
2418   Meaningless on Mac OS X and some other BSD systems as </span> <code>
2419   <span style="background-color: #FFFF00">permissions()</span></code><span style="background-color: #FFFF00"> always resolves symlinks. Get over it.</span></td>
2420 </tr>
2421
2422 </table>
2423 <h2><a name="file_status">Class file_status</a> [class.file_status]</h2>
2424 <pre>namespace boost
2425 {
2426   namespace filesystem
2427   {
2428       class file_status
2429       {
2430       public:
2431
2432         // <a href="#file_status-constructors">constructors</a>
2433         file_status() noexcept;
2434         explicit file_status(<a href="#file_type">file_type</a> ft, <a href="#Enum-perms">perms</a> prms = perms_not_known) noexcept;
2435
2436         // compiler generated
2437         file_status(const file_status&amp;) noexcept;
2438         file_status&amp; operator=(const file_status&amp;) noexcept;
2439        ~file_status() noexcept;
2440
2441         // <a href="#file_status-observers">observers</a>
2442         <a href="#file_type">file_type</a>  type() const noexcept;
2443         <a href="#Enum-perms">perms</a>      permissions() const noexcept;
2444
2445         // <a href="#file_status-modifiers">modifiers</a>
2446         void       type(<a href="#file_type">file_type</a> ft) noexcept;
2447         void       permissions(<a href="#Enum-perms">perms</a> prms) noexcept;
2448       };
2449   }  // namespace filesystem
2450 }  // namespace boost</pre>
2451 <p>An object of type <code>file_status</code> stores information about the type
2452 and permissions of a file.</p>
2453 <h3><a name="file_status-constructors"><code>file_status</code> constructors</a>
2454 [file_status.cons]</h3>
2455 <pre>explicit file_status() noexcept;</pre>
2456 <blockquote>
2457   <p><i>Postconditions:</i> <code>type() == status_error</code>, <code>permissions() == perms_not_known</code>.</p>
2458 </blockquote>
2459 <pre>explicit file_status(<a href="#file_type">file_type</a> ft, <a href="#Enum-perms">perms</a> prms = perms_not_known) noexcept;</pre>
2460 <blockquote>
2461   <p><i>Postconditions:</i> <code>type() == ft</code>, <code>permissions() == prms</code>.</p>
2462 </blockquote>
2463   <h3><a name="file_status-observers"><code>file_status</code> observers</a> [file_status.obs]</h3>
2464 <pre><a href="#file_type">file_type</a> type() const noexcept;</pre>
2465 <blockquote>
2466   <p><i>Returns: </i>The value of <code>type()</code> specified by the <i>postconditions</i> of the most recent call to a constructor, operator=, or <code>type(file_type)</code> function.</p>
2467 </blockquote>
2468 <pre><a href="#Enum-perms">perms</a> permissions() const noexcept;</pre>
2469 <blockquote>
2470   <p><i>Returns: </i>The value of <code>permissions()</code> specified by the <i>postconditions</i> of the most recent call to a constructor, operator=, or <code>permissions(perms)</code> function.</p>
2471 </blockquote>
2472 <h3><a name="file_status-modifiers"><code>file_status</code> modifiers</a> [file_status.mods]</h3>
2473 <pre>void type(<a href="#file_type">file_type</a> ft) noexcept;</pre>
2474 <blockquote>
2475   <p><i>Postconditions:</i> <code>type() == ft</code>.</p>
2476 </blockquote>
2477 <pre>void permissions(<a href="#Enum-perms">perms</a> prms) noexcept;</pre>
2478 <blockquote>
2479   <p><i>Postconditions:</i> <code>permissions() == prms</code>.</p>
2480 </blockquote>
2481 <h2><a name="Class-directory_entry">Class <code>directory_entry</code></a> [class.directory_entry]</h2>
2482
2483 <pre>namespace boost
2484 {
2485   namespace filesystem
2486   {
2487       class directory_entry
2488       {
2489       public:
2490
2491         // <a href="#directory_entry-constructors">constructors</a> and destructor
2492         directory_entry();
2493         directory_entry(const directory_entry&amp;);
2494         explicit directory_entry(const path&amp; p, file_status st=file_status(),
2495           file_status symlink_st=file_status());
2496        ~directory_entry();
2497
2498         // <a href="#directory_entry-modifiers">modifiers</a>
2499         directory_entry&amp; operator=(const directory_entry&amp;);
2500         void assign(const path&amp; p, file_status st=file_status(),
2501           file_status symlink_st=file_status());
2502         void replace_filename(const path&amp; p, file_status st=file_status(),
2503           file_status symlink_st=file_status());
2504
2505         // <a href="#directory_entry-observers">observers</a>
2506         const path&amp;  path() const;
2507         file_status  status() const;
2508         file_status  status(system::error_code&amp; ec) const;
2509         file_status  symlink_status() const;
2510         file_status  symlink_status(system::error_code&amp; ec) const;
2511
2512         bool operator&lt; (const directory_entry&amp; rhs);
2513         bool operator==(const directory_entry&amp; rhs);
2514         bool operator!=(const directory_entry&amp; rhs);
2515         bool operator&lt; (const directory_entry&amp; rhs);
2516         bool operator&lt;=(const directory_entry&amp; rhs);
2517         bool operator&gt; (const directory_entry&amp; rhs);
2518         bool operator&gt;=(const directory_entry&amp; rhs);
2519       private:
2520         path                 m_path;           // for exposition only
2521         mutable file_status  m_status;         // for exposition only; stat()-like
2522         mutable file_status  m_symlink_status; // for exposition only; lstat()-like
2523       };
2524
2525   }  // namespace filesystem
2526 }  // namespace boost</pre>
2527
2528 <p>A <code>directory_entry</code> object stores a <code>path object</code>,
2529 a <code>file_status</code> object for non-symbolic link status, and a <code>file_status</code> object for symbolic link status. The <code>file_status</code> objects act as value caches.</p>
2530 <blockquote>
2531 <p>[<i>Note:</i> Because <code>status()</code>on a pathname may be a relatively expensive operation,
2532 some operating systems provide status information as a byproduct of directory
2533 iteration. Caching such status information can result is significant time savings. Cached and
2534 non-cached results may differ in the presence of file system races. <i>—end note</i>]</p>
2535 <p><span style="background-color: #E0E0E0"><i>Actual cold-boot timing of iteration over
2536 a directory with 15,047 entries was six seconds for non-cached status queries
2537 versus one second for cached status queries. Windows XP, 3.0 GHz processor, with
2538 a moderately fast hard-drive. Similar speedups are expected on Linux and BSD-derived
2539 systems that provide status as a by-product of directory iteration.</i></span></p>
2540 </blockquote>
2541 <h3> <a name="directory_entry-constructors"> <code>directory_entry </code>constructors</a>
2542 [directory_entry.cons]</h3>
2543 <pre>directory_entry();</pre>
2544 <blockquote>
2545   <p><i>Postcondition:</i></p>
2546   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="36%">
2547     <tr>
2548       <td width="18%"><b>Expression</b></td>
2549       <td width="82%"><b>Value</b></td>
2550     </tr>
2551     <tr>
2552       <td width="18%"><code>path().empty()</code></td>
2553       <td width="82%"><code>true</code></td>
2554     </tr>
2555     <tr>
2556       <td width="18%"><code>status()</code></td>
2557       <td width="82%"><code>file_status()</code></td>
2558     </tr>
2559     <tr>
2560       <td width="18%"><code>symlink_status()</code></td>
2561       <td width="82%"><code>file_status()</code></td>
2562     </tr>
2563   </table>
2564 </blockquote>
2565 <pre>explicit directory_entry(const path&amp; p, file_status st=file_status(), file_status symlink_st=file_status());</pre>
2566 <blockquote>
2567   <p><i>Postcondition:</i></p>
2568   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="36%">
2569     <tr>
2570       <td width="18%"><b>Expression</b></td>
2571       <td width="82%"><b>Value</b></td>
2572     </tr>
2573     <tr>
2574       <td width="18%"><code>path()</code></td>
2575       <td width="82%"><code>p</code></td>
2576     </tr>
2577     <tr>
2578       <td width="18%"><code>status()</code></td>
2579       <td width="82%"><code>st</code></td>
2580     </tr>
2581     <tr>
2582       <td width="18%"><code>symlink_status()</code></td>
2583       <td width="82%"><code>symlink_st</code></td>
2584     </tr>
2585   </table>
2586 </blockquote>
2587 <h3> <a name="directory_entry-modifiers"> <code>directory_entry </code>modifiers</a>
2588 [directory_entry.mods]</h3>
2589 <pre>void assign(const path&amp; p, file_status st=file_status(), file_status symlink_st=file_status());</pre>
2590 <blockquote>
2591   <p><i>Postcondition:</i></p>
2592   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="36%">
2593     <tr>
2594       <td width="18%"><b>Expression</b></td>
2595       <td width="82%"><b>Value</b></td>
2596     </tr>
2597     <tr>
2598       <td width="18%"><code>path()</code></td>
2599       <td width="82%"><code>p</code></td>
2600     </tr>
2601     <tr>
2602       <td width="18%"><code>status()</code></td>
2603       <td width="82%"><code>st</code></td>
2604     </tr>
2605     <tr>
2606       <td width="18%"><code>symlink_status()</code></td>
2607       <td width="82%"><code>symlink_st</code></td>
2608     </tr>
2609   </table>
2610 </blockquote>
2611 <pre>void replace_filename(const path&amp; p, file_status st=file_status(), file_status symlink_st=file_status());</pre>
2612 <blockquote>
2613   <p><i>Postcondition:</i></p>
2614   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="43%">
2615     <tr>
2616       <td width="18%"><b>Expression</b></td>
2617       <td width="82%"><b>Value</b></td>
2618     </tr>
2619     <tr>
2620       <td width="18%"><code>path()</code></td>
2621       <td width="82%"><code>path().branch() / s</code></td>
2622     </tr>
2623     <tr>
2624       <td width="18%"><code>status()</code></td>
2625       <td width="82%"><code>st</code></td>
2626     </tr>
2627     <tr>
2628       <td width="18%"><code>symlink_status()</code></td>
2629       <td width="82%"><code>symlink_st</code></td>
2630     </tr>
2631   </table>
2632 </blockquote>
2633 <h3> <a name="directory_entry-observers"> <code>directory_entry</code> observers</a>
2634 [directory_entry.obs]</h3>
2635 <pre>const path&amp; path() const;</pre>
2636 <blockquote>
2637   <p><i>Returns:</i> <code>m_path</code></p>
2638 </blockquote>
2639 <pre>file_status status() const;
2640 file_status status(system::error_code&amp; ec) const;</pre>
2641 <blockquote>
2642 <p><i>Effects:</i> As if,</p>
2643   <blockquote>
2644     <pre>if ( !status_known( m_status ) )
2645 {
2646   if ( status_known(m_symlink_status) &amp;&amp; !is_symlink(m_symlink_status) )
2647     { m_status = m_symlink_status; }
2648   else { m_status = status(m_path<i>[, ec]</i>); }
2649 }</pre>
2650   </blockquote>
2651   <p><i>Returns:</i> <code>m_status</code></p>
2652
2653   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
2654
2655 </blockquote>
2656 <pre>file_status  symlink_status() const;
2657 file_status  symlink_status(system::error_code&amp; ec) const;</pre>
2658 <blockquote>
2659 <p>
2660   <i>Effects:</i> As if,</p>
2661   <blockquote>
2662     <pre>if ( !status_known( m_symlink_status ) )
2663 {
2664   m_symlink_status = symlink_status(m_path<i>[, ec]</i>);
2665 }</pre>
2666   </blockquote>
2667   <p><i>Returns:</i> <code>m_symlink_status</code></p>
2668
2669   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
2670
2671 </blockquote>
2672 <pre>bool operator==(const directory_entry&amp; rhs);</pre>
2673 <blockquote>
2674   <p><i>Returns:</i> <code>m_path == rhs.m_path</code>.</p>
2675 </blockquote>
2676 <pre>bool operator!=(const directory_entry&amp; rhs);</pre>
2677 <blockquote>
2678   <p><i>Returns:</i> <code>m_path != rhs.m_path</code>.</p>
2679 </blockquote>
2680 <pre>bool operator&lt; (const directory_entry&amp; rhs);</pre>
2681 <blockquote>
2682   <p><i>Returns:</i> <code>m_path &lt; rhs.m_path</code>.</p>
2683 </blockquote>
2684 <pre>bool operator&lt;=(const directory_entry&amp; rhs);</pre>
2685 <blockquote>
2686   <p><i>Returns:</i> <code>m_path &lt;= rhs.m_path</code>.</p>
2687 </blockquote>
2688 <pre>bool operator&gt; (const directory_entry&amp; rhs);</pre>
2689 <blockquote>
2690   <p><i>Returns:</i> <code>m_path &gt; rhs.m_path</code>.</p>
2691 </blockquote>
2692 <pre>bool operator&gt;=(const directory_entry&amp; rhs);</pre>
2693 <blockquote>
2694   <p><i>Returns:</i> <code>m_path &gt;= rhs.m_path</code>.</p>
2695 </blockquote>
2696 <h2><a name="Class-directory_iterator">Class <code>directory_iterator</code>
2697 [class.directory_iterator]</a></h2>
2698 <p>Objects of type <code>directory_iterator</code> provide standard library
2699 compliant iteration over the contents of a directory. Also see class <code><a href="#Class-recursive_directory_iterator">recursive_directory_iterator</a></code>.</p>
2700 <pre>namespace boost
2701 {
2702   namespace filesystem
2703   {
2704       class directory_iterator
2705       {
2706       public:
2707         // <a href="#directory_iterator-members">member functions</a>
2708
2709         directory_iterator() noexcept;  // creates the &quot;end&quot; iterator
2710         directory_iterator(const directory_iterator&amp;);
2711         explicit directory_iterator(const path&amp; p, <a href="#directory_options">directory_options</a> opts = directory_options::none);
2712         directory_iterator(const path&amp; p, system::error_code&amp; ec);
2713         directory_iterator(const path&amp; p, <a href="#directory_options">directory_options</a> opts, system::error_code&amp; ec);
2714        ~directory_iterator();
2715
2716         directory_iterator&amp; operator=(const directory_iterator&amp;);
2717
2718         directory_iterator&amp; operator++();
2719         directory_iterator&amp; increment(system::error_code&amp; ec);
2720
2721         // other members as required by
2722         //  C++ Std, 24.1.1 Input iterators [input.iterators]
2723       };
2724
2725   }  // namespace filesystem
2726 }  // namespace boost</pre>
2727 <p> <code>directory_iterator</code> satisfies the requirements of an
2728 input iterator (C++ Std, 24.2.1, Input iterators [input.iterators]).</p>
2729 <p>A <code>directory_iterator</code> reads successive elements from the directory for
2730 which it was constructed, as if by calling ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/readdir_r.html">readdir() or readdir_r()</a></code>. After a <code>directory_iterator</code> is constructed, and every time <code>operator++</code> is called,
2731 it reads a directory element and stores information about it in an object of type <code><a href="#Class-directory_entry">directory_entry</a></code>. <code>operator++</code> is not equality preserving; that is, <code>i == j</code> does not imply that <code>++i == ++j</code>. </p>
2732 <blockquote>
2733 <p>[<i>Note:</i> The practical consequence of not preserving equality is that directory iterators
2734 can only be used for single-pass algorithms. <i>—end note</i>]</p>
2735 </blockquote>
2736 <p>If the end of the directory elements is reached, the iterator shall become equal to
2737 the end iterator value. The constructor <code>directory_iterator()</code> with no arguments always constructs an end iterator object, which
2738 shall be the only valid iterator for the end condition. The result of <code>operator*</code> on an end iterator is not defined. For any other iterator value
2739 a <code>const directory_entry&amp;</code> is returned. The result of <code>operator-&gt;</code> on an end iterator is
2740 undefined behavior. For any other iterator value a <code>const directory_entry*</code> is
2741 returned. </p>
2742 <p>Two end iterators are always equal. An end iterator shall not be equal to a non-end
2743 iterator.</p>
2744 <blockquote>
2745 <p><i><span style="background-color: #E0E0E0">The above wording is based on the
2746 Standard Library's istream_iterator wording.</span></i></p>
2747 </blockquote>
2748 <p>The result of calling the <code>path()</code> member of the <code>directory_entry</code> object obtained by dereferencing a <code>directory_iterator</code> is a reference to a <code>path</code> object composed of the directory argument from which the iterator was
2749 constructed with filename of the directory entry appended as if by <code>operator/=</code>. </p>
2750 <p>Directory iteration shall not yield directory entries for the current (<i>dot</i>)
2751 and parent (<i>dot dot</i>) directories.</p>
2752 <p>The order of directory entries obtained by dereferencing successive
2753 increments of a <code>directory_iterator</code> is unspecified.</p>
2754 <blockquote>
2755 <p>[<i>Note:</i> Programs performing directory iteration may wish to test if the
2756 path obtained by dereferencing a directory iterator actually exists. It could be
2757 a
2758 symbolic link to a non-existent file. Programs recursively
2759 walking directory trees for purposes of removing and renaming entries may wish
2760 to avoid following symbolic links.</p>
2761 <p>If a file is removed from or added to a directory after the
2762 construction of a <code>directory_iterator</code> for the directory, it is
2763 unspecified whether or not subsequent incrementing of the iterator will ever
2764 result in an iterator whose value is the removed or added directory entry. See
2765 ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/readdir_r.html">readdir_r()</a></code>. <i>—end note</i>]</p>
2766 </blockquote>
2767 <h3><a name="directory_iterator-members"><code>directory_iterator</code> members</a>
2768 [directory_iterator.members]</h3>
2769
2770 <p><code><a name="directory_iterator-default-ctor">directory_iterator</a>()
2771 noexcept;</code></p>
2772
2773 <blockquote>
2774
2775 <p><i>Effects:</i> Constructs the end iterator.</p>
2776
2777 </blockquote>
2778
2779 <pre><code>explicit <a name="directory_iterator-ctor-path">directory_iterator</a>(</code>const path&amp; p, <a href="#directory_options">directory_options</a> opts = directory_options::none<code>);
2780 directory_iterator(</code>const path&amp; p, system::error_code&amp; ec<code>);
2781 directory_iterator(</code>const path&amp; p, <a href="#directory_options">directory_options</a> opts, system::error_code&amp; ec<code>);</code></pre>
2782 <blockquote>
2783
2784 <p><i>Effects:</i> Constructs an iterator representing the first
2785 entry in the directory <code>p</code> resolves to, if any; otherwise, the end iterator.
2786 If opening the directory fails with a <code>permission_denied</code> error and <code>(opts &amp; directory_options::skip_permission_denied) != 0</code>,
2787 constructs the end iterator and ignores the error (the operation completes successfully). If <code>opts</code> is not specified, it is assumed to be <code>directory_options::none</code>.</p>
2788
2789 <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
2790
2791 <p>[<i>Note:</i> To iterate over the current directory, use <code>directory_iterator(&quot;.&quot;)</code> rather than <code>directory_iterator(&quot;&quot;)</code>. <i>—end note</i>]</p>
2792 </blockquote>
2793 <pre>directory_iterator&amp; <a name="directory_iterator-increment">operator++</a>();
2794 directory_iterator&amp; increment(system::error_code&amp; ec);</pre>
2795 <blockquote>
2796
2797 <p><i>Effects:</i> As specified by the C++ Standard, 24.1.1 Input iterators [input.iterators]. In case of error the iterator is left in the end state.</p>
2798
2799 <p><i>Returns:</i> <code>*this</code>.</p>
2800
2801 <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
2802
2803 </blockquote>
2804 <h3><a name="directory_iterator-non-member-functions"><code>directory_iterator</code> non-member functions</a></h3>
2805 <pre>const directory_iterator&amp; begin(const directory_iterator&amp; iter);</pre>
2806 <blockquote>
2807   <p><i>Returns: </i><code>iter</code>.</p>
2808 </blockquote>
2809 <pre>directory_iterator end(const directory_iterator&amp;);</pre>
2810 <blockquote>
2811   <p><i>Returns: </i><code>directory_iterator()</code>.</p>
2812 </blockquote>
2813 <h2><a name="Class-recursive_directory_iterator">Class <code>recursive_directory_iterator</code>
2814 [class.rec.dir.itr]</a></h2>
2815 <p>Objects of type <code>recursive_directory_iterator</code> provide standard library
2816 compliant iteration over the contents of a directory, including recursion into
2817 its sub-directories.</p>
2818 <pre>namespace boost
2819 {
2820   namespace filesystem
2821   {
2822       class recursive_directory_iterator :
2823         public iterator&lt;input_iterator_tag, directory_entry&gt;
2824       {
2825       public:
2826
2827         // constructors and destructor
2828         recursive_directory_iterator() noexcept;
2829         recursive_directory_iterator(const recursive_directory_iterator&amp;);
2830         explicit recursive_directory_iterator(const path&amp; p,
2831           <a href="#directory_options">directory_options</a> opts = directory_options::none);
2832         recursive_directory_iterator(const path&amp; p,
2833           <a href="#directory_options">directory_options</a> opts, system::error_code&amp; ec);
2834         // deprecated constructors, use overloads accepting directory_options instead
2835         explicit recursive_directory_iterator(const path&amp; p,
2836           <a href="#symlink_option">symlink_option</a> opts = symlink_option::none);
2837         recursive_directory_iterator(const path&amp; p,
2838           <a href="#symlink_option">symlink_option</a> opts, system::error_code&amp; ec);
2839         recursive_directory_iterator(const path&amp; p, system::error_code&amp; ec);
2840        ~recursive_directory_iterator();
2841
2842         // observers
2843         int depth() const noexcept;
2844         bool recursion_pending() const noexcept;
2845
2846         // deprecated observers
2847         int level() const noexcept;
2848         bool no_push_pending() const noexcept;
2849
2850         // modifiers
2851         recursive_directory_iterator&amp; operator=(const recursive_directory_iterator&amp;);
2852
2853         recursive_directory_iterator&amp; operator++();
2854         recursive_directory_iterator&amp; increment(system::error_code&amp; ec);
2855
2856         void pop();
2857         void pop(system::error_code&amp; ec);
2858         void disable_recursion_pending(bool value = true) noexcept;
2859
2860         // deprecated modifiers
2861         void no_push(bool value = true);
2862
2863         // other members as required by
2864         //  C++ Std, Input iterators [input.iterators]
2865
2866       private:
2867 <i><b>        // actual data members will probably be stored in a shared object,
2868         // or some similar mechanism, to achieve the required input iterator
2869         // copy semantics</b></i>
2870         int            m_depth;              <b><i>// for exposition only</i></b>
2871         bool           m_recursion_pending;  <i><b>// for exposition only</b></i>
2872         <a href="#directory_options">directory_options</a> m_options;         <i><b>// for exposition only</b></i>
2873       };
2874
2875   }  // namespace filesystem
2876 }  // namespace boost</pre>
2877
2878 <p>The behavior of a <code>recursive_directory_iterator</code> is the same
2879 as a <code>directory_iterator</code> unless otherwise specified.</p>
2880 <ul>
2881   <li>Incrementing a <code>recursive_directory_iterator</code> pointing to a
2882   directory causes that directory itself to be iterated over, as specified by
2883   the <code>operator++</code> and <code>increment</code> functions.<br>
2884 &nbsp;</li>
2885   <li>When a <code>recursive_directory_iterator</code> reaches the end of the directory currently being iterated
2886   over, or when <code>pop()</code> is called, <code>m_depth</code> is
2887   decremented, and iteration of the parent directory continues.</li>
2888 </ul>
2889 <pre>recursive_directory_iterator() noexcept;</pre>
2890 <blockquote>
2891
2892 <p><i>Effects:</i> Constructs the end iterator.</p>
2893
2894 </blockquote>
2895
2896 <pre>explicit recursive_directory_iterator(const path&amp; p, <a href="#directory_options">directory_options</a> opts = directory_options::none);
2897 recursive_directory_iterator(const path&amp; p, <a href="#directory_options">directory_options</a> opts, system::error_code&amp; ec);
2898 explicit recursive_directory_iterator(const path&amp; p, <a href="#symlink_option">symlink_option</a> opts = symlink_option::none);
2899 recursive_directory_iterator(const path&amp; p, <a href="#symlink_option">symlink_option</a> opts, system::error_code&amp; ec);
2900 recursive_<code>directory_iterator(</code>const path&amp; p, system::error_code&amp; ec<code>);</code></pre>
2901 <blockquote>
2902
2903 <p><i>Effects:</i>&nbsp; Constructs an iterator representing the first
2904 entry in the directory <code>p</code> resolves to, if any; otherwise, the end iterator.</p>
2905
2906 <p><i>Postcondition: </i>Unless the end iterator was constructed,<i> </i><code>depth() == 0 &amp;&amp; recursion_pending() == true &amp;&amp; m_options == opts</code>.
2907 For the signature without the <code>opts</code> argument, <code>opts</code> is assumed to be <code>directory_options::none</code>.</p>
2908
2909 <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
2910
2911 <p>[<i>Note:</i> To iterate over the current directory, use <code>recursive_directory_iterator(&quot;.&quot;)</code> rather than <code>recursive_directory_iterator(&quot;&quot;)</code>. <i>—end note</i>]</p>
2912
2913 <p>[<i>Note:</i> By default, <code>recursive_directory_iterator</code> does not
2914 follow directory symlinks. To follow directory symlinks, specify <code>directory_options::follow_directory_symlink</code> in <code>opts</code>. <i>—end note</i>]</p>
2915 </blockquote>
2916 <pre>int depth() const noexcept;
2917 int level() const noexcept;</pre>
2918 <blockquote>
2919   <p><i>Requires:</i> <code>*this != recursive_directory_iterator()</code>.</p>
2920   <p><i>Returns:</i> <code>m_depth</code>.</p>
2921 </blockquote>
2922 <pre>bool recursion_pending() const noexcept;</pre>
2923 <blockquote>
2924   <p><i>Requires:</i> <code>*this != recursive_directory_iterator()</code>.</p>
2925   <p><i>Returns:</i> <code>m_recursion_pending</code>.</p>
2926 </blockquote>
2927 <pre>bool no_push_pending() const noexcept;</pre>
2928 <blockquote>
2929   <p><i>Requires:</i> <code>*this != recursive_directory_iterator()</code>.</p>
2930   <p><i>Returns:</i> <code>!recursion_pending()</code>.</p>
2931 </blockquote>
2932 <pre><code>recursive_directory_iterator</code>&amp; <a name="recursive_directory_iterator-increment">operator++</a>();
2933 recursive_directory_iterator&amp; increment(system::error_code&amp; ec);</pre>
2934 <blockquote>
2935
2936 <p><i>Effects:</i> As specified by the C++ Standard, 24.1.1 Input iterators [input.iterators],
2937 except:</p>
2938
2939 <ul>
2940   <li>
2941
2942 <p>if <code>recursion_pending() &amp;&amp; is_directory(this-&gt;status())
2943 &amp;&amp; (!is_symlink(this-&gt;symlink_status()) || (m_options &amp; directory_options::follow_directory_symlink) != 0)</code> then:
2944   <ul>
2945     <li>
2946       <p>directory <code>(*this)-&gt;path()</code> is opened and recursively iterated into and <code>m_depth</code> is incremented;</p>
2947     </li>
2948     <li>
2949       <p>if opening the directory fails with a <code>permission_denied</code> error and <code>(m_options &amp; directory_options::skip_permission_denied) != 0</code>,
2950       increment the iterator on the current level and ignore the error (the operation completes successfully).</p>
2951     </li>
2952   </ul>
2953 </p>
2954
2955   </li>
2956   <li>if there are no more directory entries at this level then <code>m_depth</code>
2957 is decremented and iteration of the parent directory resumes.</li>
2958 </ul>
2959
2960 <p>If the operation completes with an error, then
2961   <ul>
2962     <li>if <code>(m_options &amp; directory_options::pop_on_error) != 0</code>, the iterator is left in a state as if after repeatedly calling <code>pop()</code> until it succeeds or the iterator becomes equal to an end iterator; any <code>pop()</code> failures are not reported to the caller;</li>
2963     <li>otherwise, the iterator is left equal to an end iterator.</li>
2964   </ul>
2965 </p>
2966
2967 <p><i>Postcondition:</i> <code>recursion_pending() == true</code>.</p>
2968
2969 <p><i>Returns:</i> <code>*this</code>.</p>
2970
2971 <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
2972
2973 </blockquote>
2974 <pre>void pop();
2975 void pop(system::error_code&amp; ec);</pre>
2976 <blockquote>
2977   <p><i>Requires:</i> <code>*this != recursive_directory_iterator()</code>.</p>
2978   <p><i>Effects:</i> If <code>depth() == 0</code>, set <code>*this</code> to <code>recursive_directory_iterator()</code>.
2979   Otherwise, <code>--m_depth</code>, cease iteration of the directory currently being
2980   iterated over, and continue iteration over the parent directory.</p>
2981   <p>If the operation completes with an error, then
2982     <ul>
2983       <li>if <code>(m_options &amp; directory_options::pop_on_error) != 0</code>, the iterator is left in a state as if after repeatedly calling <code>pop()</code> until it succeeds or the iterator becomes equal to an end iterator; any <code>pop()</code> failures are not reported to the caller;</li>
2984       <li>otherwise, the iterator is left equal to an end iterator.</li>
2985     </ul>
2986   </p>
2987 </blockquote>
2988 <pre>void disable_recursion_pending(bool value = true) noexcept;
2989 void no_push(bool value = true) noexcept;</pre>
2990 <blockquote>
2991   <p><i>Requires:</i> <code>*this != recursive_directory_iterator()</code>.</p>
2992   <p><i>Postcondition:</i> <code>recursion_pending() == !value</code>.</p>
2993   <p>[<i>Note:</i> These functions are used to prevent
2994   unwanted recursion into a directory. <i>—end note</i>]</p>
2995 </blockquote>
2996 <h3><a name="recursive_directory_iterator-non-member-functions"><code>recursive_directory_iterator</code> non-member functions</a></h3>
2997 <pre>const recursive_directory_iterator&amp; begin(const recursive_directory_iterator&amp; iter);</pre>
2998 <blockquote>
2999   <p><i>Returns: </i><code>iter</code>.</p>
3000 </blockquote>
3001 <pre>recursive_directory_iterator end(const recursive_directory_iterator&amp;);</pre>
3002 <blockquote>
3003   <p><i>Returns: </i><code>recursive_directory_iterator()</code>.</p>
3004 </blockquote>
3005 <h2><a name="Operational-functions">Operational functions</a> [fs.op.funcs]</h2>
3006 <p>Operational functions query or modify files, including directories, in external
3007 storage.</p>
3008 <p>Operational functions access a file by resolving an
3009 object of class <code>path</code> to a particular file in a file hierarchy. The
3010 path is resolved as if by the ISO/IEC 9945 <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap04.html#tag_04_11">Pathname Resolution</a> mechanism.</p>
3011 <p>[<i>Note: </i>Because hardware failures, network failures, <a href="#file-system-race">file system races</a>, and many
3012 other kinds of errors occur frequently in file system operations, users should be aware
3013 that any filesystem operational function, no matter how apparently innocuous, may encounter
3014 an error.&nbsp;See <a href="#Error-reporting">Error reporting</a>. <i>—end note</i>]</p>
3015 <pre>path <a name="absolute">absolute</a>(const path&amp; p, const path&amp; base=current_path());</pre>
3016   <blockquote>
3017   <p><i>Returns:</i> A <a href="#Absolute-path">absolute path</a> composed according to the
3018   following table</p>
3019   <table border="1" cellpadding="5" cellspacing="0" bordercolor="#111111" style="border-collapse: collapse">
3020     <tr>
3021       <td align="center">&nbsp;</td>
3022       <td align="center"><b><code>p.<br>
3023       has_root_directory()</code></b></td>
3024       <td align="center"><b><code>!p.has_root_directory()</code></b></td>
3025     </tr>
3026     <tr>
3027       <td align="center"><b><code>p.has_root_name()</code></b></td>
3028       <td align="left"><code>return p</code></td>
3029       <td align="left"><code>return<br>
3030 &nbsp;p.root_name()<br>
3031 &nbsp;/ absolute(base)<br>
3032 &nbsp;&nbsp;&nbsp; .root_directory()<br>
3033       &nbsp;/ absolute(base)<br>
3034 &nbsp;&nbsp;&nbsp; .relative_path()<br>
3035 &nbsp;/ p.relative_path()</code></td>
3036     </tr>
3037     <tr>
3038       <td align="center"><b><code>!p.has_root_name()</code></b></td>
3039       <td align="left"><code>return<br>
3040 &nbsp;absolute(base)<br>
3041 &nbsp; .root_name()<br>
3042       &nbsp;/ p</code></td>
3043       <td align="left"><code>return absolute(base)<br>
3044 &nbsp;/ p</code></td>
3045     </tr>
3046   </table>
3047   <p>[<i>Note:</i> For the returned path, <code>rp,</code> <code>rp.is_absolute()</code> is true. <i>—end note</i>]</p>
3048   <p><i>Throws:</i> If <code>base.is_absolute()</code> is true, throws only if
3049   memory allocation fails.</p>
3050 </blockquote>
3051 <pre>path <a name="canonical">canonical</a>(const path&amp; p, const path&amp; base = current_path());
3052 path canonical(const path&amp; p, system::error_code&amp; ec);
3053 path canonical(const path&amp; p, const path&amp; base, system::error_code&amp; ec);</pre>
3054 <blockquote>
3055 <p><i>Overview:</i> Converts <code>p</code>, which must exist, to an absolute
3056 path that has no symbolic link, <a href="#Dot">dot</a>,
3057 or <a href="#Dot">dot-dot</a> elements. </p>
3058 <p><i>Returns:</i> A <a href="#canonical-path">canonical path</a> that refers to
3059 the same file system object as <code>absolute(p,base)</code>. For the overload
3060 without a <code>base</code> argument, <code>base</code> is <code>current_path()</code>.</p>
3061   <p><i>Throws:</i>&nbsp; As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3062
3063   <p><i>Remarks:</i> <code>!exists(p)</code> is an error.</p>
3064
3065   <p>[<i>Note:</i> Canonical pathnames allow security checking of a path (eg.
3066   does this path live in /home/goodguy or /home/badguy?)&nbsp; â€”end note]</p>
3067
3068 </blockquote>
3069 <pre>void <a name="copy">copy</a>(const path&amp; from, const path&amp; to);
3070 void copy(const path&amp; from, const path&amp; to, system::error_code&amp; ec);</pre>
3071 <blockquote>
3072   <p><i>Effects:</i> As if</p>
3073
3074   <blockquote>
3075     <pre>file_status s(symlink_status(from<i>[</i><code>, ec</code><i>]</i>));
3076 if(is_symlink(s))
3077   copy_symlink(from, to<i>[</i><code>, ec</code><i>]</i>);
3078 else if(is_directory(s))
3079   copy_directory(from, to<i>[</i><code>, ec</code><i>]</i>);
3080 else if(is_regular_file(s))
3081   copy_file(from, to, copy_option::fail_if_exists<i>[</i><code>, ec</code><i>]</i>);
3082 else
3083 <i> Report error as specified in <a href="#Error-reporting">Error reporting</a>.</i></pre>
3084   </blockquote>
3085   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3086
3087 </blockquote>
3088 <pre>void <a name="copy_directory">copy_directory</a>(const path&amp; from, const path&amp; to);
3089 void copy_directory(const path&amp; from, const path&amp; to, system::error_code&amp; ec);</pre>
3090 <blockquote>
3091   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
3092    bordercolor="#111111" width="90%" bgcolor="#E0E0E0">
3093     <tr>
3094       <td width="100%">
3095       <p><i>This function is poorly named; it should probably be an overload of
3096       <code>create_directory</code> with an additional argument.</i></td>
3097     </tr>
3098   </table>
3099
3100   <p><i>Effects: </i>Creates directory <code>to</code>, with
3101   attributes copied from directory <code>from</code>. The set of attributes
3102   copied is operating system dependent.</p>
3103
3104 <blockquote>
3105   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
3106    bordercolor="#111111" width="90%" bgcolor="#E8FFE8">
3107     <tr>
3108       <td width="100%">
3109       <p>[<i>Note:</i> For ISO 9945/POSIX based operating systems the
3110       attributes are those copied by native API <code>stat(from.c_str(), &amp;from_stat)</code>
3111       followed by <code>mkdir(to.c_str(),from_stat.st_mode)</code>.&nbsp; For
3112       Windows based operating systems the attributes are those copied by native
3113       API <code>CreateDirectoryExW(from.c_str(), to.c_str(), 0)</code>.&nbsp; <i>
3114       â€”end note</i>]</td>
3115     </tr>
3116   </table>
3117 </blockquote>
3118
3119   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3120
3121 </blockquote>
3122
3123 <pre>void copy_file(const path&amp; from, const path&amp; to);
3124 void copy_file(const path&amp; from, const path&amp; to, system::error_code&amp; ec);</pre>
3125 <blockquote>
3126   <p><i>Effects: </i><code>copy_file(from, to, copy_option::fail_if_exists</code><i>[</i><code>, ec</code><i>]</i><code>)</code>.</p>
3127
3128   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3129
3130 </blockquote>
3131 <pre>void <a name="copy_file">copy_file</a>(const path&amp; from, const path&amp; to, <a href="#copy_option">copy_option</a> option);
3132 void <a name="copy_file2">copy_file</a>(const path&amp; from, const path&amp; to, <a href="#copy_option">copy_option</a> option, system::error_code&amp; ec);</pre>
3133 <blockquote>
3134   <p><i>Effects:</i> If <code>option == copy_option::</code><code>fail_if_exists &amp;&amp; exists(to)</code>, an error is reported. Otherwise, the contents and attributes of the file <code>from</code> resolves to are copied to the file <code>to</code> resolves to.</p>
3135   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3136 </blockquote>
3137 <pre>void <a name="copy_symlink">copy_symlink</a>(const path&amp; existing_symlink, const path&amp; new_symlink);
3138 void copy_symlink(const path&amp; existing_symlink, const path&amp; new_symlink, system::error_code&amp; ec);</pre>
3139 <blockquote>
3140   <p><i>Effects: </i><code>create_symlink(read_symlink(existing_symlink</code><i>[</i><code>, ec</code><i>]</i><code>), new_symlink</code><i>[</i><code>, ec</code><i>]</i><code>)</code>.</p>
3141
3142   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3143
3144 </blockquote>
3145 <pre>bool <a name="create_directories">create_directories</a>(const path&amp; p);
3146 bool <a name="create_directories2">create_directories</a>(const path&amp; p, system::error_code&amp; ec);</pre>
3147 <blockquote>
3148   <p><i>Effects:</i> Establishes the postcondition by calling <code>
3149   create_directory()</code> for any element of <code>p</code> that does not
3150   exist.</p>
3151   <p><i>Postcondition:</i> <code>is_directory(p)</code></p>
3152   <p><i>Returns:</i> <code>true</code> if a new directory was created, otherwise <code>
3153   false</code>.</p>
3154   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3155   <p><i>Complexity:</i> <i>O(n+1)</i> where <i>n</i> is the number of elements
3156   of <code>p</code> that do not exist.</p>
3157 </blockquote>
3158 <pre>bool <a name="create_directory">create_directory</a>(const path&amp; p);
3159 bool <a name="create_directory2">create_directory</a>(const path&amp; p, system::error_code&amp; ec);</pre>
3160 <blockquote>
3161   <p><i>Effects:</i> Establishes the postcondition by attempting to create the
3162   directory <code>p</code> resolves to, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mkdir.html">
3163   mkdir()</a></code> with a second argument of S_IRWXU|S_IRWXG|S_IRWXO. Creation
3164   failure because <code>p</code> resolves to an existing directory shall not be
3165   treated as an error. </p>
3166   <p><i>Postcondition:</i> <code>is_directory(p)</code></p>
3167   <p><i>Returns:</i> <code>true</code> if a new directory was created, otherwise <code>false</code>.</p>
3168   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3169 </blockquote>
3170 <pre>void <a name="create_directory_symlink">create_directory_symlink</a>(const path&amp; to, const path&amp; new_symlink);
3171 void create_directory_symlink(const path&amp; to, const path&amp; new_symlink, system::error_code&amp; ec);</pre>
3172 <blockquote>
3173   <p><i>Effects:</i> Establishes the postcondition, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/symlink.html">symlink()</a></code>.</p>
3174   <p><i>
3175   Postcondition:</i> <code>new_symlink</code> resolves to a symbolic link file that
3176   contains an unspecified representation of <code>to</code>.</p>
3177   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3178   <p>[<i>Note:</i> Some operating systems, such as Windows, require symlink creation to
3179   identify that the link is to a directory. Portable code should use <code>create_directory_symlink()</code> to create directory symlinks rather than <code>create_symlink()</code> <i>—end note</i>]</p>
3180   <p>[<i>Note:</i> Some operating systems do not support symbolic links at all or support
3181   them only for regular files.
3182   Some file systems do not
3183   support
3184   symbolic links regardless of the operating system - the FAT file system used on
3185   memory cards and flash drives, for example. <i>—end note</i>]</p>
3186   </blockquote>
3187 <pre>void <a name="create_hard_link">create_hard_link</a>(const path&amp; to, const path&amp; new_hard_link);
3188 void <a name="create_hard_link2">create_hard_link</a>(const path&amp; to, const path&amp; new_hard_link, system::error_code&amp; ec);</pre>
3189 <blockquote>
3190   <p><i>Effects:</i> Establishes the postcondition, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/link.html">link()</a></code>.</p>
3191   <p><i>Postcondition:</i></p>
3192   <ul>
3193     <li>&nbsp;<code>exists(to) &amp;&amp;
3194     exists(</code><code>new_hard_link</code><code>) &amp;&amp; equivalent(to,
3195
3196     </code><code>new_hard_link</code><code>)</code></li>
3197     <li>The contents of the file or directory
3198     <code>to</code> resolves to are unchanged.</li>
3199   </ul>
3200   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3201   <p>[<i>Note:</i> Some operating systems do not support hard links at all or support
3202   them only for regular files. Some file systems do not support hard
3203   links regardless of the operating system - the FAT file system used on memory
3204   cards and flash drives, for example. Some file systems limit the number of
3205   links per file. <i>—end note</i>]</p>
3206   </blockquote>
3207 <pre>void <a name="create_symlink">create_symlink</a>(const path&amp; to, const path&amp; new_symlink);
3208 void <a name="create_symlink2">create_symlink</a>(const path&amp; to, const path&amp; new_symlink, system::error_code&amp; ec);</pre>
3209 <blockquote>
3210   <p><i>Effects:</i> Establishes the postcondition, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/symlink.html">symlink()</a></code>.</p>
3211   <p><i>
3212   Postcondition:</i> <code>new_symlink</code> resolves to a symbolic link file that
3213   contains an unspecified representation of <code>to</code>.</p>
3214   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3215   <p>[<i>Note:</i> Some operating systems do not support symbolic links at all or support
3216   them only for regular files.
3217   Some file systems do not
3218   support
3219   symbolic links regardless of the operating system - the FAT system used on
3220   memory cards and flash drives, for example. <i>—end note</i>]</p>
3221   </blockquote>
3222 <pre>path <a name="current_path">current_path</a>();
3223 path <a name="current_path2">current_path</a>(system::error_code&amp; ec);</pre>
3224 <blockquote>
3225   <p><i>Returns:</i> The current working directory path, as if by ISO/IEC
3226   9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/getcwd.html">getcwd()</a></code>. <code>is_absolute()</code> is true for the returned path.</p>
3227   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3228   <p>[<i>Note: </i>The <code>current_path()</code> name was chosen to emphasize that the return is a
3229   path, not just a single directory name.</p>
3230   <p>The current path as returned by many operating systems is a dangerous
3231   global variable. It may be changed unexpectedly by a third-party or system
3232   library functions, or by another thread.&nbsp; <i>—end note</i>]</p>
3233 </blockquote>
3234 <pre>void current_path(const path&amp; p);
3235 void current_path(const path&amp; p, system::error_code&amp; ec);</pre>
3236 <blockquote>
3237   <p><i>Effects:</i> Establishes the postcondition, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/chdir.html">chdir()</a></code>.</p>
3238 <p><i>Postcondition:</i> <code>equivalent(p, current_path())</code>.</p>
3239 <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3240   <p>[<i>Note: </i>The current path for many operating systems is a dangerous
3241   global state. It may be changed unexpectedly by a third-party or system
3242   library functions, or by another thread.&nbsp; <i>—end note</i>]</p>
3243 </blockquote>
3244 <pre>bool <a name="exists">exists</a>(file_status s) noexcept;</pre>
3245 <blockquote>
3246   <p><i>Returns:</i> <code>status_known(s) &amp;&amp; s.type() != file_not_found</code></p>
3247 </blockquote>
3248 <pre>bool <a name="exists2">exists</a>(const path&amp; p);
3249 bool <a name="exists3">exists</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</pre>
3250 <blockquote>
3251   <p><i>Returns:</i> <code>exists(status(p))</code> or <code>exists(status(p, ec))</code>,
3252   respectively. If ec != 0 and an error</p>
3253 <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3254 </blockquote>
3255 <pre><code>bool <a name="equivalent">equivalent</a>(const path&amp; p1, const path&amp; p2);
3256 bool <a name="equivalent2">equivalent</a>(const path&amp; p1, const path&amp; p2, system::error_code&amp; ec);</code></pre>
3257 <blockquote>
3258   <p><i>Effects:</i> Determines <code>file_status s1</code> and <code>s2</code>, as if by <code>status(p1)</code> and&nbsp; <code>status(p2)</code>,
3259   respectively.</p>
3260   <p><i>Returns:</i> <code>true</code>, if <code>sf1 ==
3261   sf2</code> and <code>p1</code> and <code>p2</code> resolve to the same file
3262   system entity, else <code>false</code>.</p>
3263   <blockquote>
3264   <p>Two paths are considered to resolve to the same
3265   file system entity if two candidate entities reside on the same device at the
3266   same location. This is determined as if by the values of the ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">stat</a></code> structure<code>,</code> obtained as if by <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code> for the two paths, having equal <code>st_dev</code> values
3267   and equal <code>st_ino</code> values.</p>
3268   <p>[<i>Note:</i> ISO/IEC 9945 requires that <i>&quot;st_dev</i> must be unique within a Local Area Network&quot;. Conservative
3269   ISO/IEC 9945 implementations may also wish to check for equal <code>st_size</code> and <code>st_mtime</code> values. <i>Windows</i> implementations may use <code>GetFileInformationByHandle()</code> as a surrogate for <code>stat()</code>,
3270   and consider &quot;same&quot; to be equal values for <code>dwVolumeSerialNumber</code>, <code>nFileIndexHigh</code>, <code>nFileIndexLow</code>, <code>nFileSizeHigh</code>, <code>nFileSizeLow</code>, <code>ftLastWriteTime.dwLowDateTime</code>, and <code>ftLastWriteTime.dwHighDateTime</code>. <i>—end note</i>]</p>
3271   </blockquote>
3272   <p><i>Throws:</i> <code>filesystem_error</code> if <code>(!exists(s1) &amp;&amp; !exists(s2)) || (is_other(s1) &amp;&amp; is_other(s2))</code>,
3273   otherwise as specified in <a href="#Error-reporting">Error reporting</a>.</p>
3274 </blockquote>
3275
3276 <pre>uintmax_t <a name="file_size">file_size</a>(const path&amp; p);
3277 uintmax_t <a name="file_size2">file_size</a>(const path&amp; p, system::error_code&amp; ec);</pre>
3278
3279 <blockquote>
3280   <p><i>Returns:</i> If <code>exists(p) &amp;&amp; is_regular_file(p)</code>, the size
3281   in bytes
3282   of the file <code>p</code> resolves to, determined as if by the value of
3283   the ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">stat</a></code> structure member <code>st_size</code> obtained as if by
3284   ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code>.
3285   Otherwise, <code>static_cast&lt;uintmax_t&gt;(-1)</code>.</p>
3286   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3287 </blockquote>
3288 <pre>uintmax_t <a name="hard_link_count">hard_link_count</a>(const path&amp; p);
3289 uintmax_t hard_link_count(const path&amp; p, system::error_code&amp; ec);</pre>
3290 <blockquote>
3291
3292   <p><i>Returns:</i> The number of hard links for <code>p</code>.</p>
3293   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3294
3295 </blockquote>
3296
3297 <pre>const path&amp; <a name="initial_path">initial_path</a>();
3298 const path&amp; <a name="initial_path2">initial_path</a>(<code>system::error_code&amp; ec</code>);</pre>
3299 <blockquote>
3300   <p><i>Returns:</i> <code>current_path()</code> as of the first call to <code>initial_path()</code>.</p>
3301   <p>[<i>Note:</i> <code>initial_path()</code> is not thread safe, and may return an undesirable result
3302   if called subsequent to a change to the current directory. These problems can
3303   be avoided by calling <code>initial_path()</code> immediately on entry to
3304   main().&nbsp; <i>—end note</i>]</p>
3305   <p><i>Throws:</i> For the first call, as specified in <a href="#Error-reporting">Error reporting</a>. Subsequent calls throw nothing.</p>
3306 </blockquote>
3307 <pre>bool <code><a name="is_directory">is_directory</a></code>(file_status s) noexcept;</pre>
3308 <blockquote>
3309   <p><i>Returns:</i> <code>s.type() == directory_file</code></p>
3310 </blockquote>
3311 <pre><code>bool <a name="is_directory2">is_directory</a>(const path&amp; p);
3312 bool <a name="is_directory3">is_directory</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
3313 <blockquote>
3314   <p><i>Returns:</i> <code>is_directory(status(p))</code> or <code>is_directory(status(p, ec))</code>,
3315   respectively.</p>
3316 <p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws
3317 nothing.</p>
3318 </blockquote>
3319 <pre><code>bool <a name="is_empty">is_empty</a>(const path&amp; p);
3320 bool <a name="is_empty2">is_empty</a></a>(const path&amp; p, system::error_code&amp; ec);</code></pre>
3321 <blockquote>
3322   <p><i>Effects:</i> Determines <code>file_status s</code>, as if by <code>status(p, ec)</code>.</p>
3323   <p><i>Returns:</i> <code>is_directory(s)<br>
3324 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ? directory_iterator(p) == directory_iterator()<br>
3325 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : file_size(p) == 0;</code></p>
3326 </blockquote>
3327 <pre>bool <code><a name="is_regular_file">is_regular_file</a></code>(file_status s) noexcept;</pre>
3328 <blockquote>
3329   <p><i>Returns:</i> <code>s.type() == regular_file</code></p>
3330 </blockquote>
3331 <pre><code>bool <a name="is_regular_file2">is_regular_file</a>(const path&amp; p);</code></pre>
3332 <blockquote>
3333   <p><i>Returns:</i> <code>is_regular_file(status(p))</code>.</p>
3334   <p><i>Throws:</i> <code>filesystem_error</code> if <code>status(p)</code> would throw <code>filesystem_error.</code></p>
3335   </blockquote>
3336 <pre><code>bool <a name="is_regular_file3">is_regular_file</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
3337 <blockquote>
3338   <p><i>Effects:</i> Sets <code>ec</code> as if by <code>status(p, ec)</code>. [<i>Note:</i> <code>status_error</code>, <code>file_not_found</code> and <code>type_unknown</code> cases set <code>ec</code> to error values. To distinguish between cases, call the <code>status</code> function directly. <i>—end
3339   note</i>] </p>
3340   <p><i>Returns:</i> <code>is_regular_file(status(p, ec))</code>.</p>
3341 </blockquote>
3342 <pre>bool <a name="is_other">is_other</a>(file_status s) noexcept;</pre>
3343 <blockquote>
3344   <p><i>Returns:</i> <code>return exists(s) &amp;&amp; !is_regular_file(s) &amp;&amp; !is_directory(s) &amp;&amp; !is_symlink(s)</code></p>
3345 </blockquote>
3346 <pre><code>bool <a name="is_other2">is_other</a>(const path&amp; p);
3347 bool <a name="is_other3">is_other</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
3348 <blockquote>
3349   <p><i>Returns:</i> <code>is_other(status(p))</code> or <code>is_other(status(p, ec))</code>,
3350   respectively.</p>
3351   <p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws
3352   nothing.</p>
3353 </blockquote>
3354 <pre>bool <a name="is_symlink">is_symlink</a>(file_status s) noexcept;</pre>
3355 <blockquote>
3356   <p><i>Returns:</i> <code>s.type() == symlink_file</code></p>
3357 </blockquote>
3358 <pre><code>bool <a name="is_symlink2">is_symlink</a>(const path&amp; p);
3359 bool <a name="is_symlink3">is_symlink</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</code></pre>
3360 <blockquote>
3361   <p><i>Returns:</i> <code>is_symlink(symlink_status(p))</code> or <code>is_symlink(symlink_status(p, ec))</code>,
3362   respectively.</p>
3363   <p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws
3364   nothing.</p>
3365 </blockquote>
3366 <pre>std::time_t <a name="last_write_time">last_write_time</a>(const path&amp; p);
3367 std::time_t <a name="last_write_time2">last_write_time</a>(const path&amp; p<code>, system::error_code&amp; ec</code>);</pre>
3368 <blockquote>
3369   <p><i>Returns:</i> The time of last data modification of <code>p</code>, determined as if by the
3370   value of the ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">stat</a></code> structure member <code>st_mtime</code>&nbsp; obtained
3371   as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code>.</p>
3372   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3373 </blockquote>
3374 <pre>void <a name="last_write_time3">last_write_time</a>(const path&amp; p, const std::time_t new_time);
3375 void <a name="last_write_time4">last_write_time</a>(const path&amp; p, const std::time_t new_time<code>, system::error_code&amp; ec</code>);</pre>
3376 <blockquote>
3377   <p><i>Effects:</i> Sets the time of last data modification of the file
3378   resolved to by <code>p</code> to <code>new_time</code>, as if by ISO/IEC
3379   9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code> followed by
3380   ISO/IEC 9945 <a href="http://www.opengroup.org/onlinepubs/000095399/functions/utime.html"><code>utime()</code></a>.</p>
3381   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3382   <p>[<i>Note:</i> A postcondition of <code>last_write_time(p) == new_time</code> is not specified since it might not hold for file systems
3383   with coarse time granularity. <i>—end note</i>]</p>
3384 </blockquote>
3385 <pre>void <a name="permissions">permissions</a>(const path&amp; p, <a href="#symlink_perms">perms</a> prms);
3386 void permissions(const path&amp; p, <a href="#symlink_perms">perms</a> prms, system::error_code&amp; ec);</pre>
3387 <blockquote>
3388   <p>
3389   <i>Requires:</i> <code>!((prms &amp; add_perms) &amp;&amp; (prms &amp; remove_perms))</code>.</p>
3390   <p><i>Effects:</i> Applies the effective permissions bits from <code>prms</code> to the file <code>p</code> resolves to, as if by
3391   ISO/IEC 9945 <code><a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchmodat.html">fchmodat()</a></code>. The effective permission bits are determined as
3392   specified by the following table. </p>
3393   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
3394     <tr>
3395       <td><b>bits present in <code>prms</code></b></td>
3396       <td><b>Effective bits applied</b></td>
3397     </tr>
3398     <tr>
3399       <td>Neither <code>add_perms</code> nor <code>remove_perms</code></td>
3400       <td><code>prms &amp; perms_mask</code></td>
3401     </tr>
3402     <tr>
3403       <td><code>add_perms</code></td>
3404       <td>
3405       <p><code>status(p).permissions() | (prms &amp; <a href="#perms_mask">perms_mask</a>)</code> </td>
3406     </tr>
3407     <tr>
3408       <td><code>remove_perms</code></td>
3409       <td><code>status(p)</code><code>.permissions() &amp; ~(prms &amp; <a href="#perms_mask">perms_mask</a>) </code></td>
3410     </tr>
3411   </table>
3412   <p>[<i>Note:</i> Conceptually permissions are viewed as bits, but the actual
3413   implementation may use some other mechanism. -- <i>end note</i>]</p>
3414   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3415 </blockquote>
3416 <pre>path <a name="read_symlink">read_symlink</a>(const path&amp; p);
3417 path read_symlink(const path&amp; p, system::error_code&amp; ec);</pre>
3418 <blockquote>
3419   <p><i>Returns:</i>&nbsp; If <code>p</code> resolves to a symbolic
3420   link, a <code>path</code> object containing the contents of that symbolic
3421   link. Otherwise an empty <code>path</code> object.</p>
3422   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>. [<i>Note:</i> It is an error if <code>p</code> does not
3423   resolve to a symbolic link. <i>—end note</i>]</p>
3424 </blockquote>
3425 <pre>path <a name="op-relative">relative</a>(const path&amp; p, system::error_code&amp; ec);</pre>
3426 <blockquote>
3427   <p><i>Returns:</i> <code>relative(p, current_path(), ec)</code>.</p>
3428   <p><i>Throws:</i>&nbsp; As specified in Error reporting.</p>
3429 </blockquote>
3430 <pre>path relative(const path&amp; p, const path&amp; base=current_path());
3431 path relative(const path&amp; p, const path&amp; base, system::error_code&amp; ec);</pre>
3432 <blockquote>
3433   <p><i>Overview:</i> Returns <code>p</code> made relative to <code>base</code>.
3434   Treats empty or identical paths as corner cases, not errors. Resolves symlinks
3435   and normalizes both <code>p</code> and <code>base</code> before other
3436   processing.</p>
3437   <p><i>Returns:</i> <code><a href="#weakly_canonical">weakly_canonical</a>(p).<a href="#lex-relative">lexically_relative</a>(<a href="#weakly_canonical">weakly_canonical</a>(base))</code>. The second form returns <code>path()</code>
3438   if an error occurs.</p>
3439   <p><i>Throws:</i> As specified in Error reporting.</p>
3440 </blockquote>
3441 <pre>bool <a name="remove">remove</a>(const path&amp; p);
3442 bool <a name="remove2">remove</a>(const path&amp; p, system::error_code&amp; ec);</pre>
3443 <blockquote>
3444   <p><i>Effects:</i>&nbsp; If <code>exists(symlink_status(p,ec))</code>, it is
3445   removed
3446   as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/remove.html">remove()</a></code>.</p>
3447   <blockquote>
3448   <p>[<i>Note:</i> A symbolic link is itself removed, rather than the file it
3449   resolves to being removed. <i>—end note</i>]</p>
3450   </blockquote>
3451   <p><i>Postcondition:</i> <code>!exists(symlink_status(p))</code>.</p>
3452   <p><i>Returns:</i>&nbsp; <code>false</code> if p did not exist in the first
3453   place, otherwise <code>true</code>.</p>
3454   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3455 </blockquote>
3456 <pre>uintmax_t <a name="remove_all">remove_all</a>(const path&amp; p);
3457 uintmax_t <a name="remove_all2">remove_all</a>(const path&amp; p, system::error_code&amp; ec);</pre>
3458 <blockquote>
3459   <p><i>Effects:</i>&nbsp; Recursively deletes the contents of p if it exists,
3460   then deletes file <code>p</code> itself,
3461   as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/remove.html">remove()</a></code>.</p>
3462   <blockquote>
3463   <p>[<i>Note:</i> A symbolic link is itself removed, rather than the file it
3464   resolves to being removed. <i>—end note</i>]</p>
3465   </blockquote>
3466   <p><i>Postcondition:</i> <code>!exists(p)</code></p>
3467   <p><i>Returns:</i> The number of files removed.</p>
3468   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3469 </blockquote>
3470 <pre>void <a name="rename">rename</a>(const path&amp; old_p, const path&amp; new_p);
3471 void <a name="rename2">rename</a>(const path&amp; old_p, const path&amp; new_p, system::error_code&amp; ec);</pre>
3472 <blockquote>
3473   <p><i>Effects:</i> Renames <code>old_p</code> to <code>new_p</code>, as if by
3474   ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/rename.html">rename()</a></code>.</p>
3475   <blockquote>
3476   <p>[<i>Note:</i> If <code>old_p</code> and <code>new_p</code> resolve to the
3477   same existing file, no action is taken. Otherwise, if <code>new_p</code> resolves to an
3478   existing non-directory file, it is removed, while if <code>new_p</code> resolves to an
3479   existing directory, it is removed if empty on ISO/IEC 9945 but is an error on Windows. A symbolic link is itself renamed, rather than
3480   the file it resolves to being renamed. <i>—end note</i>]</p>
3481   </blockquote>
3482   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3483 </blockquote>
3484 <pre>void <a name="resize_file">resize_file</a>(const path&amp; p, uintmax_t new_size);
3485 void <a name="resize_file2">resize_file</a>(const path&amp; p, uintmax_t new_size, system::error_code&amp; ec);</pre>
3486 <blockquote>
3487 <p><i>Postcondition:</i> <code>file_size() == new_size</code>.</p>
3488 <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3489   <p><i>Remarks:</i> Achieves its postconditions as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/truncate.html">truncate()</a></code>.</p>
3490 </blockquote>
3491 <pre>space_info <a name="space">space</a>(const path&amp; p);
3492 space_info <a name="space2">space</a>(const path&amp; p, system::error_code&amp; ec);</pre>
3493 <blockquote>
3494   <p><i>Returns:</i> An object of type <code><a href="#space_info">space_info</a></code>. The value of the <code>space_info</code> object is determined as if by
3495   using ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/statvfs.html"
3496    style="text-decoration: none">statvfs()</a></code> to obtain an ISO/IEC 9945 struct
3497   <code><a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/statvfs.h.html" style="text-decoration: none">statvfs</a></code>,
3498    and then multiplying its <code>f_blocks</code>, <code>f_bfree</code>,
3499    and <code>f_bavail</code> members by its <code>f_frsize</code> member,
3500    and assigning the results to the <code>capacity</code>, <code>free</code>,
3501   and <code>available</code> members respectively. Any members for which the
3502   value cannot be determined shall be set to -1.</p>
3503   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3504 </blockquote>
3505 <pre><a href="#file_status">file_status</a> <a name="status">status</a>(const path&amp; p);</pre>
3506 <blockquote>
3507   <p><i>Effects: </i>As if:</p>
3508   <blockquote>
3509     <pre>system::error_code ec;
3510 file_status result = status(p, ec);
3511 if (result == status_error)
3512   throw filesystem_error(<i>implementation-supplied-message</i>, p, ec);
3513 return result;</pre>
3514   </blockquote>
3515   <p><i>Returns:</i> See above.</p>
3516   <p><i>Throws:</i> <code>filesystem_error</code>.
3517 [<i>Note:</i> <code>result</code> values of <code>file_status(file_not_found)</code>and <code>file_status(type_unknown)</code> are not considered failures and do not
3518   cause an exception to be
3519 thrown.<i> â€”end note</i>] </p>
3520   </blockquote>
3521 <pre><a href="#file_status">file_status</a> <a name="status2">status</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</pre>
3522 <blockquote>
3523   <p><i>Effects: </i></p>
3524   <blockquote>
3525     <p>If possible, determines the attributes
3526     of the file <code>p</code> resolves to, as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code>.</p>
3527       If, during attribute determination, the underlying file system API reports
3528     an error, sets <code>ec</code> to indicate the specific error reported.
3529     Otherwise, <code>ec.clear()</code>.<blockquote>
3530       <p>[<i>Note:</i> This allows users to inspect the specifics of underlying
3531       API errors even when the value returned by <code>status()</code> is not <code>file_status(status_error)</code>.&nbsp; <i>—end note</i>]</p>
3532     </blockquote>
3533     </blockquote>
3534   <p><i>Returns:</i></p>
3535   <blockquote>
3536     <p>If <code>ec != error_code()</code>:</p>
3537     <ul>
3538       <li>If the specific error indicates that <code>p</code> cannot be resolved
3539       because some element of the path does not exist, return <code>
3540       file_status(file_not_found)</code>. [<i>Note:</i> ISO/IEC 9945 errors that
3541       indicate this are ENOENT or ENOTDIR. Windows equivalents
3542       include ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND, ERROR_INVALID_NAME,
3543       ERROR_INVALID_PARAMETER, ERROR_BAD_PATHNAME, and ERROR_BAD_NETPATH. <i>--
3544       end note</i>]<br>
3545 &nbsp;</li>
3546       <li>Otherwise, if the specific error indicates that <code>p</code> can be resolved
3547       but the attributes cannot be determined, return <code>
3548       file_status(type_unknown)</code>. [<i>Note: </i>For example, Windows
3549       ERROR_SHARING_VIOLATION errors. For ISO/IEC 9945, the case never arises. <i>—end
3550       note</i>]<br>
3551 &nbsp;</li>
3552       <li>Otherwise, return <code>
3553       file_status(status_error)</code>.</li>
3554     </ul>
3555         <blockquote>
3556         <p>[<i>Note:</i> These semantics distinguish between <code>p</code> being known not to exist, <code>p</code> existing but not being able to determine its attributes,
3557         and there being an error that prevents even knowing if <code>p</code> exists. These
3558         distinctions are important to some use cases.&nbsp;<i>—end note</i>]</p>
3559     </blockquote>
3560     <p>Otherwise,</p>
3561     <ul>
3562       <li>If the attributes indicate a regular file, as if by ISO/IEC 9945&nbsp;<a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISREG()</a>,
3563       return <code>
3564       file_status(regular_file)</code>. [<i>Note:</i> <code>
3565 regular_file</code> implies appropriate <code>&lt;fstream&gt;</code> operations
3566       would succeed, assuming no hardware, permission, access, or file system
3567       race
3568       errors. Lack of
3569 <code>regular_file</code> does not necessarily imply <code>&lt;fstream&gt;</code> operations would
3570 fail on a directory.
3571 <i>—end note</i>]<br>
3572 &nbsp;</li>
3573       <li>Otherwise, if the attributes indicate a directory, as if by ISO/IEC 9945
3574       <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISDIR()</a>,
3575       return <code>
3576       file_status(directory_file)</code>. [<i>Note:</i> <code>directory_file</code> implies <code>
3577 directory_iterator(p)</code>would succeed.
3578 <i>—end note</i>]<br>
3579 &nbsp;</li>
3580       <li>Otherwise, if the attributes indicate a block special file, as if by ISO/IEC 9945
3581       <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISBLK()</a>,
3582       return <code>
3583       file_status(block_file)</code>.<br>
3584 &nbsp;</li>
3585       <li>Otherwise, if the attributes indicate a character special file, as if by ISO/IEC 9945
3586       <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISCHR()</a>,
3587       return <code>
3588       file_status(character_file)</code>.<br>
3589 &nbsp;</li>
3590       <li>Otherwise, if the attributes indicate a fifo or pipe file, as if by
3591       ISO/IEC 9945
3592       <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISFIFO()</a>,
3593       return <code>
3594       file_status(fifo_file)</code>.<br>
3595 &nbsp;</li>
3596       <li>Otherwise, if the attributes indicate a socket, as if by ISO/IEC
3597       9945
3598       <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISSOCK()</a>,
3599       return <code>
3600       file_status(socket_file)</code>.<br>
3601 &nbsp;</li>
3602       <li>Otherwise, return <code>
3603       file_status(type_unknown)</code>.</li>
3604     </ul>
3605     </blockquote>
3606       <p><i>Remarks:</i> If a symbolic link is encountered during pathname
3607       resolution,
3608       pathname resolution continues using the contents of the symbolic link.</p>
3609 </blockquote>
3610 <pre>bool <a name="status_known">status_known</a>(file_status s) noexcept;</pre>
3611 <blockquote>
3612   <p><i>Returns:</i> <code>s.type() != status_error</code></p>
3613 </blockquote>
3614 <pre>file_status <a name="symlink_status">symlink_status</a>(const path&amp; p);
3615 file_status <a name="symlink_status2">symlink_status</a>(const path&amp; p, system::error_code&amp; ec) noexcept;</pre>
3616 <blockquote>
3617   <p><i>Effects:</i>&nbsp; Same as <a href="#status">status()</a>, above,
3618   except that the attributes
3619     of <code>p</code> are determined as if by ISO/IEC 9945 <code><a href="http://www.opengroup.org/onlinepubs/000095399/functions/lstat.html">lstat()</a></code>.</p>
3620 </blockquote>
3621 <blockquote>
3622       <p><i>Returns:</i> Same as <a href="#status">status()</a>, above, except
3623       that if the attributes indicate a symbolic link, as if by ISO/IEC 9945 <a class="external" href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html">S_ISLNK()</a>, return <code>file_status(symlink_file)</code>.</p>
3624       <p><i>Remarks:</i> Pathname resolution terminates if <code>p</code> names a symbolic link.</p>
3625   <p><i>Throws:</i> <code>filesystem_error</code>; overload with <code>error_code&amp;</code> throws
3626   nothing.</p>
3627 </blockquote>
3628 <pre>path <a name="system_complete">system_complete</a>(const path&amp; p);
3629 path <a name="system_complete2">system_complete</a>(const path&amp; p, system::error_code&amp; ec);</pre>
3630 <blockquote>
3631   <p><i>Effects:</i> Composes an absolute path from <code>p</code>, using the
3632   same rules used by the operating system to resolve a path passed as the
3633   filename argument to standard library open functions.</p>
3634   <p><i>Returns:</i> The composed path.</p>
3635   <p><i>Postcondition:</i> For the returned path, <code>rp,</code> <code>rp.is_absolute()</code> is true.</p>
3636   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3637   <p>[<i>Note:</i> For ISO/IEC 9945, <code>system_complete(p)</code> has the same semantics as <code>complete(p, current_path())</code>.</p>
3638   <p><a name="windows_effects">For <i>Windows</i></a>, <code>system_complete(p)</code> has the
3639   same semantics as <code>complete(ph, current_path())</code> if <code>p.is_absolute() || !p.has_root_name()</code> or <code>p</code> and <code>base</code> have the same <code>root_name()</code>.
3640   Otherwise it acts like <code>complete(p, kinky)</code>, where <code>kinky</code> is the current directory for the <code>p.root_name()</code> drive. This will
3641   be the current directory of that drive the last time it was set, and thus may
3642   be <b>residue left over from a prior program</b> run by the command
3643   processor! Although these semantics are often useful, they are also very
3644   error-prone.</p>
3645   <p>See <a href="#complete_note"><i>complete()</i> note</a> for usage suggestions. <i>—end note</i>]</p>
3646 </blockquote>
3647 <pre>path <a name="temp_directory_path">temp_directory_path</a>();
3648 path temp_directory_path(system::error_code&amp; ec);</pre>
3649 <blockquote>
3650   <p><i>Returns:</i> A directory path suitable for temporary files under the
3651   conventions of the operating system. The specifics of how this path is
3652   determined are implementation defined. An error shall be reported if<code> !exists(p)
3653   || !is_directory(p)</code>, where <code>p</code> is the path to be returned.</p>
3654   <p>ISO/IEC 9945: The path supplied by the first environment variable found in the
3655   list TMPDIR, TMP, TEMP, TEMPDIR. If none of these are found, <code>&quot;/tmp&quot;</code>,
3656   or, if macro <code>__ANDROID__ </code>is defined, <code>&quot;/data/local/tmp&quot;</code>.</p>
3657   <p><i>Windows:</i> The path reported by the <i>Windows</i> <code>GetTempPath</code> API function.</p>
3658   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3659   <p>[<i>Note: </i>The <code>temp_directory_path()</code> name was chosen to emphasize that the return is a
3660   path, not just a single directory name.&nbsp; <i>—end note</i>]</p>
3661 </blockquote>
3662 <pre>path <a name="unique_path">unique_path</a>(const path&amp; model=&quot;%%%%-%%%%-%%%%-%%%%&quot;);
3663 path unique_path(const path&amp; model, system::error_code&amp; ec);</pre>
3664 <blockquote>
3665   <p>The <code>unique_path</code> function generates a path name suitable for
3666   creating temporary files, including directories. The name is based
3667   on a model that uses the percent sign character to specify replacement by a
3668   random hexadecimal digit. [<i>Note:</i> The more bits of randomness in the
3669   generated path name, the less likelihood of prior existence or being guessed.
3670   Each replacement hexadecimal digit in the model adds four bits of randomness.
3671   The default model thus provides 64 bits of randomness. This is sufficient for
3672   most applications. <i>—end note</i>]</p>
3673   <p><i>Returns:</i> A path identical to <code>model</code>, except that each
3674   occurrence of a percent sign character is replaced by a random hexadecimal
3675   digit character in the range 0-9, a-f.</p>
3676   <p><i>Throws:</i> As specified in <a href="#Error-reporting">Error reporting</a>.</p>
3677   <p><i>Remarks:</i> Implementations are encouraged to obtain the required
3678   randomness via a <a href="http://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator">cryptographically secure pseudo-random number generator</a>, such as one
3679   provided by the operating system. [<i>Note</i>: Such generators may block
3680   until sufficient entropy develops. <i>—end note</i>]</p>
3681 </blockquote>
3682 <pre>path <a name="weakly_canonical">weakly_canonical</a>(const path&amp; p);
3683 path weakly_canonical(const path&amp; p, system::error_code&amp; ec);</pre>
3684 <blockquote>
3685   <p><i>Overview:</i> Returns <code>p</code> with symlinks resolved and the
3686   result normalized.</p>
3687   <p><i>Returns: </i>A path composed of the result of calling the <code>
3688   canonical</code> function on a path composed of the leading elements of <code>
3689   p</code> that exist, if any, followed by the elements of <code>p</code> that
3690   do not exist, if any.</p>
3691   <p><i>Postcondition:</i> The returned path is in
3692   <a href="#normal-form">
3693   normal form</a>.</p>
3694   <p><i>Remarks:</i> Uses <code>operator/=</code> to compose the returned path.
3695   Uses the <code>status</code> function to determine existence.</p>
3696   <p><i>Remarks:</i> Implementations are encouraged to avoid unnecessary
3697   normalization such as when <code>canonical</code> has already been called on
3698   the entirety of <code>p</code>.</p>
3699   <p><i>Throws:</i>&nbsp; As specified in Error reporting.</p>
3700 </blockquote>
3701 <hr>
3702
3703 <!-- generate-section-numbers=false -->
3704
3705
3706 <h3><a name="File-streams">File streams</a> -
3707 <a href="../../../boost/filesystem/fstream.hpp">&lt;boost/filesystem/fstream.hpp&gt;</a></h3>
3708 <p>Replacements are provided for the file stream classes from the C++ standard
3709 library's <code>&lt;fstream&gt;</code> header. These replacement classes
3710 publicly inherit from the standard library classes. In the Boost.Filesystem
3711 version, constructors and open functions take <code>const path&amp;</code> arguments
3712 instead of <code>
3713 const char*</code> arguments. There are no other differences in syntax or
3714 semantics.</p>
3715 <pre>namespace boost
3716 {
3717   namespace filesystem
3718   {
3719     template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
3720     class basic_filebuf : public std::basic_filebuf&lt;charT,traits&gt;
3721     {
3722     public:
3723       basic_filebuf&lt;charT,traits&gt;*
3724         open(const path&amp; p, std::ios_base::openmode mode);
3725     };
3726
3727     template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
3728     class basic_ifstream : public std::basic_ifstream&lt;charT,traits&gt;
3729     {
3730     public:
3731       explicit basic_ifstream(const path&amp; p, std::ios_base::openmode mode=std::ios_base::in)
3732       void open(const path&amp; p, std::ios_base::openmode mode=std::ios_base::in);
3733     };
3734
3735     template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
3736     class basic_ofstream : public std::basic_ofstream&lt;charT,traits&gt;
3737     {
3738     public:
3739       explicit basic_ofstream(const path&amp; p, std::ios_base::openmode mode=std::ios_base::out);
3740       void open(const path&amp; p, std::ios_base::openmode mode=std::ios_base::out);
3741     };
3742
3743     template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
3744     class basic_fstream : public std::basic_fstream&lt;charT,traits&gt;
3745     {
3746     public:
3747       explicit basic_fstream(const path&amp; p,
3748         std::ios_base::openmode mode=std::ios_base::in | std::ios_base::out);
3749       void open(const path&amp; p,
3750         std::ios_base::openmode mode=std::ios_base::in | std::ios_base::out);
3751     };
3752
3753     typedef basic_filebuf&lt;char&gt; filebuf;
3754     typedef basic_ifstream&lt;char&gt; ifstream;
3755     typedef basic_ofstream&lt;char&gt; ofstream;
3756     typedef basic_fstream&lt;char&gt; fstream;
3757
3758     typedef basic_filebuf&lt;wchar_t&gt; wfilebuf;
3759     typedef basic_ifstream&lt;wchar_t&gt; wifstream;
3760     typedef basic_fstream&lt;wchar_t&gt; wfstream;
3761     typedef basic_ofstream&lt;wchar_t&gt; wofstream;
3762
3763   }  // namespace filesystem
3764 }  // namespace boost</pre>
3765
3766
3767
3768 <h2><a name="path-decomposition-table">Path decomposition table</a></h2>
3769 <p>The table is generated by a program compiled with the Boost implementation.</p>
3770 <p>Shaded entries indicate cases where ISO/IEC 9945 (POSIX) and Windows implementations yield different results. The top value is the
3771 ISO/IEC 9945 result and the bottom value is the Windows result. <br>
3772 <table border="1" cellspacing="0" cellpadding="5">
3773 <p>
3774 <tr><td><b>Constructor<br>argument</b></td>
3775 <td><b>Iteration<br>over<br>Elements</b></td>
3776 <td><b><code>string()</code></b></td>
3777 <td><b><code>generic_<br>string()</code></b></td>
3778 <td><b><code>root_<br>path()</code></b></td>
3779 <td><b><code>root_<br>name()</code></b></td>
3780 <td><b><code>root_<br>directory()</code></b></td>
3781 <td><b><code>relative_<br>path()</code></b></td>
3782 <td><b><code>parent_<br>path()</code></b></td>
3783 <td><b><code>filename()</code></b></td>
3784 </tr>
3785 <tr>
3786 <td><font size="-1"><i>empty</i></font></td>
3787 <td><font size="-1"><i>empty</i></font></td>
3788 <td><font size="-1"><i>empty</i></font></td>
3789 <td><font size="-1"><i>empty</i></font></td>
3790 <td><font size="-1"><i>empty</i></font></td>
3791 <td><font size="-1"><i>empty</i></font></td>
3792 <td><font size="-1"><i>empty</i></font></td>
3793 <td><font size="-1"><i>empty</i></font></td>
3794 <td><font size="-1"><i>empty</i></font></td>
3795 <td><font size="-1"><i>empty</i></font></td>
3796 </tr>
3797 <tr>
3798 <td><code>.</code></td>
3799 <td><code>.</code></td>
3800 <td><code>.</code></td>
3801 <td><code>.</code></td>
3802 <td><font size="-1"><i>empty</i></font></td>
3803 <td><font size="-1"><i>empty</i></font></td>
3804 <td><font size="-1"><i>empty</i></font></td>
3805 <td><code>.</code></td>
3806 <td><font size="-1"><i>empty</i></font></td>
3807 <td><code>.</code></td>
3808 </tr>
3809 <tr>
3810 <td><code>..</code></td>
3811 <td><code>..</code></td>
3812 <td><code>..</code></td>
3813 <td><code>..</code></td>
3814 <td><font size="-1"><i>empty</i></font></td>
3815 <td><font size="-1"><i>empty</i></font></td>
3816 <td><font size="-1"><i>empty</i></font></td>
3817 <td><code>..</code></td>
3818 <td><font size="-1"><i>empty</i></font></td>
3819 <td><code>..</code></td>
3820 </tr>
3821 <tr>
3822 <td><code>foo</code></td>
3823 <td><code>foo</code></td>
3824 <td><code>foo</code></td>
3825 <td><code>foo</code></td>
3826 <td><font size="-1"><i>empty</i></font></td>
3827 <td><font size="-1"><i>empty</i></font></td>
3828 <td><font size="-1"><i>empty</i></font></td>
3829 <td><code>foo</code></td>
3830 <td><font size="-1"><i>empty</i></font></td>
3831 <td><code>foo</code></td>
3832 </tr>
3833 <tr>
3834 <td><code>/</code></td>
3835 <td><code>/</code></td>
3836 <td><code>/</code></td>
3837 <td><code>/</code></td>
3838 <td><code>/</code></td>
3839 <td><font size="-1"><i>empty</i></font></td>
3840 <td><code>/</code></td>
3841 <td><font size="-1"><i>empty</i></font></td>
3842 <td><font size="-1"><i>empty</i></font></td>
3843 <td><code>/</code></td>
3844 </tr>
3845 <tr>
3846 <td><code>/foo</code></td>
3847 <td><code>/,foo</code></td>
3848 <td><code>/foo</code></td>
3849 <td><code>/foo</code></td>
3850 <td><code>/</code></td>
3851 <td><font size="-1"><i>empty</i></font></td>
3852 <td><code>/</code></td>
3853 <td><code>foo</code></td>
3854 <td><code>/</code></td>
3855 <td><code>foo</code></td>
3856 </tr>
3857 <tr>
3858 <td><code>foo/</code></td>
3859 <td><code>foo,.</code></td>
3860 <td><code>foo/</code></td>
3861 <td><code>foo/</code></td>
3862 <td><font size="-1"><i>empty</i></font></td>
3863 <td><font size="-1"><i>empty</i></font></td>
3864 <td><font size="-1"><i>empty</i></font></td>
3865 <td><code>foo/</code></td>
3866 <td><code>foo</code></td>
3867 <td><code>.</code></td>
3868 </tr>
3869 <tr>
3870 <td><code>/foo/</code></td>
3871 <td><code>/,foo,.</code></td>
3872 <td><code>/foo/</code></td>
3873 <td><code>/foo/</code></td>
3874 <td><code>/</code></td>
3875 <td><font size="-1"><i>empty</i></font></td>
3876 <td><code>/</code></td>
3877 <td><code>foo/</code></td>
3878 <td><code>/foo</code></td>
3879 <td><code>.</code></td>
3880 </tr>
3881 <tr>
3882 <td><code>foo/bar</code></td>
3883 <td><code>foo,bar</code></td>
3884 <td><code>foo/bar</code></td>
3885 <td><code>foo/bar</code></td>
3886 <td><font size="-1"><i>empty</i></font></td>
3887 <td><font size="-1"><i>empty</i></font></td>
3888 <td><font size="-1"><i>empty</i></font></td>
3889 <td><code>foo/bar</code></td>
3890 <td><code>foo</code></td>
3891 <td><code>bar</code></td>
3892 </tr>
3893 <tr>
3894 <td><code>/foo/bar</code></td>
3895 <td><code>/,foo,bar</code></td>
3896 <td><code>/foo/bar</code></td>
3897 <td><code>/foo/bar</code></td>
3898 <td><code>/</code></td>
3899 <td><font size="-1"><i>empty</i></font></td>
3900 <td><code>/</code></td>
3901 <td><code>foo/bar</code></td>
3902 <td><code>/foo</code></td>
3903 <td><code>bar</code></td>
3904 </tr>
3905 <tr>
3906 <td><code>//net</code></td>
3907 <td><code>//net</code></td>
3908 <td><code>//net</code></td>
3909 <td><code>//net</code></td>
3910 <td><code>//net</code></td>
3911 <td><code>//net</code></td>
3912 <td><font size="-1"><i>empty</i></font></td>
3913 <td><font size="-1"><i>empty</i></font></td>
3914 <td><font size="-1"><i>empty</i></font></td>
3915 <td><code>//net</code></td>
3916 </tr>
3917 <tr>
3918 <td><code>//net/foo</code></td>
3919 <td><code>//net,/,foo</code></td>
3920 <td><code>//net/foo</code></td>
3921 <td><code>//net/foo</code></td>
3922 <td><code>//net/</code></td>
3923 <td><code>//net</code></td>
3924 <td><code>/</code></td>
3925 <td><code>foo</code></td>
3926 <td><code>//net/</code></td>
3927 <td><code>foo</code></td>
3928 </tr>
3929 <tr>
3930 <td><code>///foo///</code></td>
3931 <td><code>/,foo,.</code></td>
3932 <td><code>///foo///</code></td>
3933 <td><code>///foo///</code></td>
3934 <td><code>/</code></td>
3935 <td><font size="-1"><i>empty</i></font></td>
3936 <td><code>/</code></td>
3937 <td><code>foo///</code></td>
3938 <td><code>///foo</code></td>
3939 <td><code>.</code></td>
3940 </tr>
3941 <tr>
3942 <td><code>///foo///bar</code></td>
3943 <td><code>/,foo,bar</code></td>
3944 <td><code>///foo///bar</code></td>
3945 <td><code>///foo///bar</code></td>
3946 <td><code>/</code></td>
3947 <td><font size="-1"><i>empty</i></font></td>
3948 <td><code>/</code></td>
3949 <td><code>foo///bar</code></td>
3950 <td><code>///foo</code></td>
3951 <td><code>bar</code></td>
3952 </tr>
3953 <tr>
3954 <td><code>/.</code></td>
3955 <td><code>/,.</code></td>
3956 <td><code>/.</code></td>
3957 <td><code>/.</code></td>
3958 <td><code>/</code></td>
3959 <td><font size="-1"><i>empty</i></font></td>
3960 <td><code>/</code></td>
3961 <td><code>.</code></td>
3962 <td><code>/</code></td>
3963 <td><code>.</code></td>
3964 </tr>
3965 <tr>
3966 <td><code>./</code></td>
3967 <td><code>.,.</code></td>
3968 <td><code>./</code></td>
3969 <td><code>./</code></td>
3970 <td><font size="-1"><i>empty</i></font></td>
3971 <td><font size="-1"><i>empty</i></font></td>
3972 <td><font size="-1"><i>empty</i></font></td>
3973 <td><code>./</code></td>
3974 <td><code>.</code></td>
3975 <td><code>.</code></td>
3976 </tr>
3977 <tr>
3978 <td><code>/..</code></td>
3979 <td><code>/,..</code></td>
3980 <td><code>/..</code></td>
3981 <td><code>/..</code></td>
3982 <td><code>/</code></td>
3983 <td><font size="-1"><i>empty</i></font></td>
3984 <td><code>/</code></td>
3985 <td><code>..</code></td>
3986 <td><code>/</code></td>
3987 <td><code>..</code></td>
3988 </tr>
3989 <tr>
3990 <td><code>../</code></td>
3991 <td><code>..,.</code></td>
3992 <td><code>../</code></td>
3993 <td><code>../</code></td>
3994 <td><font size="-1"><i>empty</i></font></td>
3995 <td><font size="-1"><i>empty</i></font></td>
3996 <td><font size="-1"><i>empty</i></font></td>
3997 <td><code>../</code></td>
3998 <td><code>..</code></td>
3999 <td><code>.</code></td>
4000 </tr>
4001 <tr>
4002 <td><code>foo/.</code></td>
4003 <td><code>foo,.</code></td>
4004 <td><code>foo/.</code></td>
4005 <td><code>foo/.</code></td>
4006 <td><font size="-1"><i>empty</i></font></td>
4007 <td><font size="-1"><i>empty</i></font></td>
4008 <td><font size="-1"><i>empty</i></font></td>
4009 <td><code>foo/.</code></td>
4010 <td><code>foo</code></td>
4011 <td><code>.</code></td>
4012 </tr>
4013 <tr>
4014 <td><code>foo/..</code></td>
4015 <td><code>foo,..</code></td>
4016 <td><code>foo/..</code></td>
4017 <td><code>foo/..</code></td>
4018 <td><font size="-1"><i>empty</i></font></td>
4019 <td><font size="-1"><i>empty</i></font></td>
4020 <td><font size="-1"><i>empty</i></font></td>
4021 <td><code>foo/..</code></td>
4022 <td><code>foo</code></td>
4023 <td><code>..</code></td>
4024 </tr>
4025 <tr>
4026 <td><code>foo/./</code></td>
4027 <td><code>foo,.,.</code></td>
4028 <td><code>foo/./</code></td>
4029 <td><code>foo/./</code></td>
4030 <td><font size="-1"><i>empty</i></font></td>
4031 <td><font size="-1"><i>empty</i></font></td>
4032 <td><font size="-1"><i>empty</i></font></td>
4033 <td><code>foo/./</code></td>
4034 <td><code>foo/.</code></td>
4035 <td><code>.</code></td>
4036 </tr>
4037 <tr>
4038 <td><code>foo/./bar</code></td>
4039 <td><code>foo,.,bar</code></td>
4040 <td><code>foo/./bar</code></td>
4041 <td><code>foo/./bar</code></td>
4042 <td><font size="-1"><i>empty</i></font></td>
4043 <td><font size="-1"><i>empty</i></font></td>
4044 <td><font size="-1"><i>empty</i></font></td>
4045 <td><code>foo/./bar</code></td>
4046 <td><code>foo/.</code></td>
4047 <td><code>bar</code></td>
4048 </tr>
4049 <tr>
4050 <td><code>foo/..</code></td>
4051 <td><code>foo,..</code></td>
4052 <td><code>foo/..</code></td>
4053 <td><code>foo/..</code></td>
4054 <td><font size="-1"><i>empty</i></font></td>
4055 <td><font size="-1"><i>empty</i></font></td>
4056 <td><font size="-1"><i>empty</i></font></td>
4057 <td><code>foo/..</code></td>
4058 <td><code>foo</code></td>
4059 <td><code>..</code></td>
4060 </tr>
4061 <tr>
4062 <td><code>foo/../</code></td>
4063 <td><code>foo,..,.</code></td>
4064 <td><code>foo/../</code></td>
4065 <td><code>foo/../</code></td>
4066 <td><font size="-1"><i>empty</i></font></td>
4067 <td><font size="-1"><i>empty</i></font></td>
4068 <td><font size="-1"><i>empty</i></font></td>
4069 <td><code>foo/../</code></td>
4070 <td><code>foo/..</code></td>
4071 <td><code>.</code></td>
4072 </tr>
4073 <tr>
4074 <td><code>foo/../bar</code></td>
4075 <td><code>foo,..,bar</code></td>
4076 <td><code>foo/../bar</code></td>
4077 <td><code>foo/../bar</code></td>
4078 <td><font size="-1"><i>empty</i></font></td>
4079 <td><font size="-1"><i>empty</i></font></td>
4080 <td><font size="-1"><i>empty</i></font></td>
4081 <td><code>foo/../bar</code></td>
4082 <td><code>foo/..</code></td>
4083 <td><code>bar</code></td>
4084 </tr>
4085 <tr>
4086 <td><code>c:</code></td>
4087 <td><code>c:</code></td>
4088 <td><code>c:</code></td>
4089 <td><code>c:</code></td>
4090 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4091 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4092 <td><font size="-1"><i>empty</i></font></td>
4093 <td><code>c:</code><br><font size="-1"><i>empty</i></font></td>
4094 <td><font size="-1"><i>empty</i></font></td>
4095 <td><code>c:</code></td>
4096 </tr>
4097 <tr>
4098 <td><code>c:/</code></td>
4099 <td><code>c:,.</code><br><code>c:,/</code></td>
4100 <td><code>c:/</code></td>
4101 <td><code>c:/</code></td>
4102 <td><font size="-1"><i>empty</i></font><br><code>c:/</code></td>
4103 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4104 <td><font size="-1"><i>empty</i></font><br><code>/</code></td>
4105 <td><code>c:/</code><br><font size="-1"><i>empty</i></font></td>
4106 <td><code>c:</code></td>
4107 <td><code>.</code><br><code>/</code></td>
4108 </tr>
4109 <tr>
4110 <td><code>c:foo</code></td>
4111 <td><code>c:foo</code><br><code>c:,foo</code></td>
4112 <td><code>c:foo</code></td>
4113 <td><code>c:foo</code></td>
4114 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4115 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4116 <td><font size="-1"><i>empty</i></font></td>
4117 <td><code>c:foo</code><br><code>foo</code></td>
4118 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4119 <td><code>c:foo</code><br><code>foo</code></td>
4120 </tr>
4121 <tr>
4122 <td><code>c:/foo</code></td>
4123 <td><code>c:,foo</code><br><code>c:,/,foo</code></td>
4124 <td><code>c:/foo</code></td>
4125 <td><code>c:/foo</code></td>
4126 <td><font size="-1"><i>empty</i></font><br><code>c:/</code></td>
4127 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4128 <td><font size="-1"><i>empty</i></font><br><code>/</code></td>
4129 <td><code>c:/foo</code><br><code>foo</code></td>
4130 <td><code>c:</code><br><code>c:/</code></td>
4131 <td><code>foo</code></td>
4132 </tr>
4133 <tr>
4134 <td><code>c:foo/</code></td>
4135 <td><code>c:foo,.</code><br><code>c:,foo,.</code></td>
4136 <td><code>c:foo/</code></td>
4137 <td><code>c:foo/</code></td>
4138 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4139 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4140 <td><font size="-1"><i>empty</i></font></td>
4141 <td><code>c:foo/</code><br><code>foo/</code></td>
4142 <td><code>c:foo</code></td>
4143 <td><code>.</code></td>
4144 </tr>
4145 <tr>
4146 <td><code>c:/foo/</code></td>
4147 <td><code>c:,foo,.</code><br><code>c:,/,foo,.</code></td>
4148 <td><code>c:/foo/</code></td>
4149 <td><code>c:/foo/</code></td>
4150 <td><font size="-1"><i>empty</i></font><br><code>c:/</code></td>
4151 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4152 <td><font size="-1"><i>empty</i></font><br><code>/</code></td>
4153 <td><code>c:/foo/</code><br><code>foo/</code></td>
4154 <td><code>c:/foo</code></td>
4155 <td><code>.</code></td>
4156 </tr>
4157 <tr>
4158 <td><code>c:/foo/bar</code></td>
4159 <td><code>c:,foo,bar</code><br><code>c:,/,foo,bar</code></td>
4160 <td><code>c:/foo/bar</code></td>
4161 <td><code>c:/foo/bar</code></td>
4162 <td><font size="-1"><i>empty</i></font><br><code>c:/</code></td>
4163 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4164 <td><font size="-1"><i>empty</i></font><br><code>/</code></td>
4165 <td><code>c:/foo/bar</code><br><code>foo/bar</code></td>
4166 <td><code>c:/foo</code></td>
4167 <td><code>bar</code></td>
4168 </tr>
4169 <tr>
4170 <td><code>prn:</code></td>
4171 <td><code>prn:</code></td>
4172 <td><code>prn:</code></td>
4173 <td><code>prn:</code></td>
4174 <td><font size="-1"><i>empty</i></font><br><code>prn:</code></td>
4175 <td><font size="-1"><i>empty</i></font><br><code>prn:</code></td>
4176 <td><font size="-1"><i>empty</i></font></td>
4177 <td><code>prn:</code><br><font size="-1"><i>empty</i></font></td>
4178 <td><font size="-1"><i>empty</i></font></td>
4179 <td><code>prn:</code></td>
4180 </tr>
4181 <tr>
4182 <td><code>c:\</code></td>
4183 <td><code>c:\</code><br><code>c:,/</code></td>
4184 <td><code>c:\</code></td>
4185 <td><code>c:\</code><br><code>c:/</code></td>
4186 <td><font size="-1"><i>empty</i></font><br><code>c:\</code></td>
4187 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4188 <td><font size="-1"><i>empty</i></font><br><code>\</code></td>
4189 <td><code>c:\</code><br><font size="-1"><i>empty</i></font></td>
4190 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4191 <td><code>c:\</code><br><code>\</code></td>
4192 </tr>
4193 <tr>
4194 <td><code>c:foo</code></td>
4195 <td><code>c:foo</code><br><code>c:,foo</code></td>
4196 <td><code>c:foo</code></td>
4197 <td><code>c:foo</code></td>
4198 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4199 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4200 <td><font size="-1"><i>empty</i></font></td>
4201 <td><code>c:foo</code><br><code>foo</code></td>
4202 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4203 <td><code>c:foo</code><br><code>foo</code></td>
4204 </tr>
4205 <tr>
4206 <td><code>c:\foo</code></td>
4207 <td><code>c:\foo</code><br><code>c:,/,foo</code></td>
4208 <td><code>c:\foo</code></td>
4209 <td><code>c:\foo</code><br><code>c:/foo</code></td>
4210 <td><font size="-1"><i>empty</i></font><br><code>c:\</code></td>
4211 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4212 <td><font size="-1"><i>empty</i></font><br><code>\</code></td>
4213 <td><code>c:\foo</code><br><code>foo</code></td>
4214 <td><font size="-1"><i>empty</i></font><br><code>c:\</code></td>
4215 <td><code>c:\foo</code><br><code>foo</code></td>
4216 </tr>
4217 <tr>
4218 <td><code>c:foo\</code></td>
4219 <td><code>c:foo\</code><br><code>c:,foo,.</code></td>
4220 <td><code>c:foo\</code></td>
4221 <td><code>c:foo\</code><br><code>c:foo/</code></td>
4222 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4223 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4224 <td><font size="-1"><i>empty</i></font></td>
4225 <td><code>c:foo\</code><br><code>foo\</code></td>
4226 <td><font size="-1"><i>empty</i></font><br><code>c:foo</code></td>
4227 <td><code>c:foo\</code><br><code>.</code></td>
4228 </tr>
4229 <tr>
4230 <td><code>c:\foo\</code></td>
4231 <td><code>c:\foo\</code><br><code>c:,/,foo,.</code></td>
4232 <td><code>c:\foo\</code></td>
4233 <td><code>c:\foo\</code><br><code>c:/foo/</code></td>
4234 <td><font size="-1"><i>empty</i></font><br><code>c:\</code></td>
4235 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4236 <td><font size="-1"><i>empty</i></font><br><code>\</code></td>
4237 <td><code>c:\foo\</code><br><code>foo\</code></td>
4238 <td><font size="-1"><i>empty</i></font><br><code>c:\foo</code></td>
4239 <td><code>c:\foo\</code><br><code>.</code></td>
4240 </tr>
4241 <tr>
4242 <td><code>c:\foo/</code></td>
4243 <td><code>c:\foo,.</code><br><code>c:,/,foo,.</code></td>
4244 <td><code>c:\foo/</code></td>
4245 <td><code>c:\foo/</code><br><code>c:/foo/</code></td>
4246 <td><font size="-1"><i>empty</i></font><br><code>c:\</code></td>
4247 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4248 <td><font size="-1"><i>empty</i></font><br><code>\</code></td>
4249 <td><code>c:\foo/</code><br><code>foo/</code></td>
4250 <td><code>c:\foo</code></td>
4251 <td><code>.</code></td>
4252 </tr>
4253 <tr>
4254 <td><code>c:/foo\bar</code></td>
4255 <td><code>c:,foo\bar</code><br><code>c:,/,foo,bar</code></td>
4256 <td><code>c:/foo\bar</code></td>
4257 <td><code>c:/foo\bar</code><br><code>c:/foo/bar</code></td>
4258 <td><font size="-1"><i>empty</i></font><br><code>c:/</code></td>
4259 <td><font size="-1"><i>empty</i></font><br><code>c:</code></td>
4260 <td><font size="-1"><i>empty</i></font><br><code>/</code></td>
4261 <td><code>c:/foo\bar</code><br><code>foo\bar</code></td>
4262 <td><code>c:</code><br><code>c:/foo</code></td>
4263 <td><code>foo\bar</code><br><code>bar</code></td>
4264 </tr>
4265 </table>
4266 <h2><a name="long-path-warning"></a>Warning: Long paths on Windows and the
4267 extended-length <b>\\?\ </b>prefix</h2>
4268 <p>The Microsoft Windows &quot;Maximum Path Length Limitation&quot; specifies:</p>
4269 <blockquote>
4270 <p>In the Windows API (with some exceptions ...), the maximum length for a path
4271 is MAX_PATH, which is defined as 260 characters.</p>
4272 <p>The Windows API has many functions that also have Unicode versions to permit
4273 an extended-length path for a maximum total path length of 32,767 characters.
4274 ... To specify an extended-length path, use the <b>&quot;\\?\&quot; prefix</b>. For
4275 example, &quot;\\?\D:\<em>very long path</em>&quot;.&nbsp; <i>[C++ string literals require backslashes be doubled, of course.]</i></p>
4276 </blockquote>
4277 <p>Because most Boost.Filesystem operational functions just pass the contents of
4278 a class path object to the Windows API, they do work with the extended-length
4279 prefixes. But some won't work, because to the limitations imposed by Windows.
4280 Read the following cautions carefully!</p>
4281 <h3>Cautions for paths with extended-length prefixes</h3>
4282 <ul>
4283   <li>Individual components of a path are still are limited to whatever is
4284   supported for the particular filesystem, commonly 255 characters.</li>
4285   <li>Only backslashes are acceptable as directory separators. Slashes are
4286   not treated as separators.</li>
4287   <li>All paths must be absolute - relative paths are not allowed.</li>
4288   <li>Once an absolute path grows beyond 260 characters, it is essentially
4289   poisoned and all operations must use extended-length prefixes. So even a
4290   simple operation like <code>create_directory(&quot;a&quot;)</code> will fail if the
4291   absolute path of the resulting directory would exceed 260 characters.</li>
4292   <li>Certain Boost.Filesystem functions that decompose their argument path and
4293   then work on individual relative directories or files will not work properly
4294   with extended-length prefix paths.</li>
4295 </ul>
4296 <h2><a name="Acknowledgements">Acknowledgements</a></h2>
4297 <p>This Filesystem Library is dedicated to my wife, Sonda, who provided the
4298 support necessary to see both a trial implementation and the proposal itself
4299 through to completion. She gave me the strength to continue after a difficult
4300 year of cancer treatment in the middle of it all.</p>
4301 <p>Many people contributed technical comments, ideas, and suggestions to the
4302 Boost Filesystem Library. See <a href="http://www.boost.org/libs/filesystem/doc/index.htm#Acknowledgements">http://www.boost.org/libs/filesystem/doc/index.htm#Acknowledgements</a>.</p>
4303 <p>Dietmar Kuehl contributed the original Boost Filesystem Library directory_iterator design. Peter Dimov, Walter Landry, Rob Stewart, and Thomas
4304 Witt were particularly helpful in refining the library.</p>
4305 <p>The create_directories, extension, basename, and replace_extension functions
4306 were developed by Vladimir Prus. The temp_directory_path function was
4307 contributed by Jeff Flinn. David Svoboda suggested the canonical function and
4308 provided pseudo-code.</p>
4309 <p>Howard Hinnant and John Maddock reviewed a draft of the version 2 proposal, and
4310 identified a number of mistakes or weaknesses, resulting in a more polished
4311 final document.</p>
4312 <p>Peter Dimov suggested a single class path, with member templates to adapt to
4313 multiple string types. His idea became the basis for the version 3 path design.</p>
4314 <h2><a name="References">References</a></h2>
4315 <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
4316   <tr>
4317     <td width="16%" valign="top">[<a name="ISO_POSIX">ISO/IEC 9945</a>]</td>
4318     <td width="84%">ISO/IEC 9945:2003, IEEE&nbsp;Std&nbsp;1003.1-2001, and The Open Group
4319     Base Specifications, Issue 6. Also known as The Single Unix<font face="Times New Roman">&reg;
4320     Specification, Version 3. Available from each of the organizations involved
4321     in its creation. For example, read online or download from <a href="http://www.unix.org/single_unix_specification/">www.unix.org/single_unix_specification/</a>.</font> The ISO JTC1/SC22/WG15 -
4322     POSIX homepage is <a href="http://www.open-std.org/jtc1/sc22/WG15/">www.open-std.org/jtc1/sc22/WG15/</a></td>
4323   </tr>
4324   <tr>
4325     <td width="16%" valign="top">[Abrahams]</td>
4326     <td width="84%">Dave Abrahams, Error and Exception Handling, <a href="http://www.boost.org/more/error_handling.html">www.boost.org/more/error_handling.html</a></td>
4327   </tr>
4328 </table>
4329 <hr>
4330 <p><font size="2">&copy; Copyright Beman Dawes, 2002, 2006, 2007, 2009, 2010, 2011</font></p>
4331 <p><font size="2">Distributed under the Boost Software License, Version 1.0. See
4332 </font>
4333 <a href="http://www.boost.org/LICENSE_1_0.txt"><font size="2">www.boost.org/LICENSE_1_0.txt</font></a></p>
4334 <p><font size="2">Revised
4335 <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->01 December 2015<!--webbot bot="Timestamp" endspan i-checksum="39286" --></font></p>
4336 </body>
4337 </html>