index.htm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
  5. <meta name="ProgId" content="FrontPage.Editor.Document">
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  7. <title>Filesystem Home</title>
  8. <link href="styles.css" rel="stylesheet">
  9. </head>
  10. <body>
  11. <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
  12. bordercolor="#111111">
  13. <tr>
  14. <td width="277">
  15. <a href="../../../index.htm">
  16. <img src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle"
  17. width="300" height="86" border="0"></a></td>
  18. <td align="middle">
  19. <font size="7">Filesystem Library<br>
  20. Version 3</font>
  21. </td>
  22. </tr>
  23. </table>
  24. <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
  25. bordercolor="#111111" bgcolor="#D7EEFF" width="100%">
  26. <tr>
  27. <td><a href="index.htm">Home</a> &nbsp;&nbsp;
  28. <a href="tutorial.html">Tutorial</a> &nbsp;&nbsp;
  29. <a href="reference.html">Reference</a> &nbsp;&nbsp;
  30. <a href="faq.htm">FAQ</a> &nbsp;&nbsp;
  31. <a href="release_history.html">Releases</a> &nbsp;&nbsp;
  32. <a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
  33. <a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
  34. <a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
  35. <a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;
  36. <a href="issue_reporting.html">Bug Reports</a>&nbsp;&nbsp;
  37. </td>
  38. </table>
  39. <p></p>
  40. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse"
  41. bordercolor="#111111" align="right">
  42. <tr>
  43. <td width="100%" bgcolor="#D7EEFF" align="center">
  44. <i><b>Contents</b></i></td>
  45. </tr>
  46. <tr>
  47. <td width="100%" bgcolor="#E8F5FF">
  48. <a href="#Introduction">Introduction</a><br>
  49. <a href="#Documentation">Documentation</a><br>
  50. <a href="#Using">Using the library</a><br>
  51. <a href="#Coding-guidelines">Coding guidelines</a><br>
  52. <a href="#Cautions">Cautions</a><br>
  53. <a href="#Headers">Headers</a><br>
  54. <a href="#Examples">Example programs</a><br>
  55. <a href="#Implementation">Implementation</a><br>
  56. <a href="#Macros">Macros</a><br>
  57. <a href="#Building">Building the object-library</a><br>
  58. <a href="#Cgywin">Notes for Cygwin users</a><br>
  59. <a href="#Change-history">Version history<br>
  60. &nbsp; with acknowledgements</a></td>
  61. </tr>
  62. </table>
  63. <p></p>
  64. <h2><a name="Introduction">Introduction</a></h2>
  65. <p>The Boost.Filesystem library provides facilities to manipulate files and directories,
  66. and the paths that identify them.</p>
  67. <p>The features of the library include:</p>
  68. <ul>
  69. <li><b>A modern C++ interface, highly compatible with the C++ standard
  70. library.</b></li>
  71. </ul>
  72. <blockquote>
  73. <blockquote>
  74. <p>Many users say the interface is their primary motivation for using
  75. Boost.Filesystem. They like its use of familiar idioms based on standard library
  76. containers, iterators, and algorithms. They like having errors reported by
  77. throwing exceptions.</p>
  78. </blockquote>
  79. </blockquote>
  80. <ul>
  81. <li><b>Portability between operating systems.</b><br>
  82. &nbsp;<ul>
  83. <li>At the C++ syntax level, it is convenient to learn and use one interface
  84. regardless of the operating system.</li>
  85. <li>At the semantic level, behavior of code is reasonably portable across
  86. operating systems.</li>
  87. <li>Dual generic or native path format support encourages program
  88. portability, yet still allows communication with users in system specific
  89. formats.<br>
  90. &nbsp;</li>
  91. </ul>
  92. </li>
  93. <li><b>Error handling and reporting via C++ exceptions (the default) or error
  94. codes.</b><br>
  95. &nbsp;<ul>
  96. <li>C++ exceptions are the preferred error reporting mechanism for most
  97. applications. The exception thrown includes the detailed error code
  98. information important for diagnosing the exact cause of file system errors.</li>
  99. <li>Error reporting via error code allows user code that provides detailed
  100. error recovery to avoid becoming so littered with try-catch blocks as to be
  101. unmaintainable. <br>
  102. &nbsp;</li>
  103. </ul>
  104. </li>
  105. <li><b>Suitable for a broad spectrum of applications, ranging from simple
  106. script-like operations to extremely complex production code.</b><br>
  107. &nbsp;<ul>
  108. <li>At the simple script-like end of the spectrum, the intent is not to
  109. compete with Python, Perl, or shell languages, but rather to provide
  110. filesystem operations when C++ is already the language of choice.</li>
  111. <li dir="ltr">
  112. <p dir="ltr">Finer grained control over operations and error handling is available to
  113. support more complex applications or other cases where throwing exceptions
  114. isn't desired.<br>
  115. &nbsp;</li>
  116. </ul>
  117. </li>
  118. <li>
  119. <p dir="ltr"><b>Forms the basis for
  120. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf">
  121. ISO/IEC TS 18822</a>, the C++ standard library Filesystem Technical
  122. Specification.</b></li>
  123. </ul>
  124. <h2><a name="Documentation">Documentation</a></h2>
  125. <p><b><a href="tutorial.html">Tutorial</a></b> - A gentle introduction to
  126. the library, with example programs provided for you to experiment with.</p>
  127. <p><b><a href="reference.html">Reference</a></b> - Formal documentation in the
  128. style of the C++ standard for
  129. every component of the library.</p>
  130. <p><b><a href="faq.htm">FAQ</a></b> - Frequently asked questions.</p>
  131. <p><b><a href="portability_guide.htm">Portability Guide</a></b> - Help for those
  132. concerned with writing code to run on multiple operating systems.</p>
  133. <p><b><a href="deprecated.html">Deprecated Features</a></b> - Identifies
  134. deprecated features and their replacements.</p>
  135. <p><b><a href="v3.html">Version 3 Introduction</a></b> - Aimed at users of prior
  136. Boost.Filesystem versions.</p>
  137. <p><b><a href="v3_design.html">Version 3 Design</a></b> - Historical document
  138. from the start of the Version 3 design process.</p>
  139. <p><b><a href="design.htm">Original Design</a></b> - Historical document from
  140. the start of the Version 1 design process.</p>
  141. <p><b><a href="do_list.html">Do List</a></b> - Boost.Filesystem development work
  142. in the pipeline.</p>
  143. <h2><a name="Using">Using</a> the library</h2>
  144. <p>Boost.Filesystem is implemented as a separately compiled library, so you must install
  145. binaries in a location that can be found by your linker. If you followed the
  146. <a href="http://www.boost.org/doc/libs/release/more/getting_started/index.html">Boost Getting Started</a> instructions, that's already been done for you.</p>
  147. <h2><a name="Coding-guidelines">Coding guidelines</a></h2>
  148. <p>For new code, defining <code>BOOST_FILESYSTEM_NO_DEPRECATED</code> before
  149. including filesystem headers is strongly recommended. This prevents inadvertent
  150. use of old features, particularly legacy function names, that have been replaced
  151. and are going to go away in the future.</p>
  152. <h2><a name="Cautions">Cautions</a></h2>
  153. <p>After reading the tutorial you can dive right into simple,
  154. script-like programs using the Filesystem Library! Before doing any serious
  155. work, however, there a few cautions to be aware of:</p>
  156. <h4><b>Effects and Postconditions not guaranteed in the presence of race-conditions</b></h4>
  157. <p>Filesystem function specifications follow the C++ Standard Library form, specifying behavior in terms of
  158. effects and postconditions. If
  159. a <a href="reference.html#Race-condition">race-condition</a> exists, a function's
  160. postconditions may no longer be true by the time the function returns to the
  161. caller.</p>
  162. <blockquote>
  163. <p><b><i>Explanation: </i></b>The state of files and directories is often
  164. globally shared, and thus may be changed unexpectedly by other threads,
  165. processes, or even other computers having network access to the filesystem. As an
  166. example of the difficulties this can cause, note that the following asserts
  167. may fail:</p>
  168. <blockquote>
  169. <p><code>assert( exists( &quot;foo&quot; ) == exists( &quot;foo&quot; ) );&nbsp; //
  170. (1)<br>
  171. <br>
  172. remove_all( &quot;foo&quot; );<br>
  173. assert( !exists( &quot;foo&quot; ) );&nbsp; // (2)<br>
  174. <br>
  175. assert( is_directory( &quot;foo&quot; ) == is_directory( &quot;foo&quot; ) ); //
  176. (3)</code></p>
  177. </blockquote>
  178. <p>(1) will fail if a non-existent &quot;foo&quot; comes into existence, or an
  179. existent &quot;foo&quot; is removed, between the first and second call to <i>exists()</i>.
  180. This could happen if, during the execution of the example code, another thread,
  181. process, or computer is also performing operations in the same directory.</p>
  182. <p>(2) will fail if between the call to <i>remove_all()</i> and the call to
  183. <i>exists()</i> a new file or directory named &quot;foo&quot; is created by another
  184. thread, process, or computer.</p>
  185. <p>(3) will fail if another thread, process, or computer removes an
  186. existing file &quot;foo&quot; and then creates a directory named &quot;foo&quot;, between the
  187. example code's two calls to <i>is_directory()</i>.</p>
  188. </blockquote>
  189. <h4>E<b>xceptions</b></h4>
  190. <p>Unless otherwise specified, Boost.Filesystem functions throw <i>
  191. <a href="reference.html#basic_filesystem_error-constructors">basic_filesystem_error</a></i>
  192. exceptions to report failures such as I/O errors. Implementations may also use C++ Standard Library functions
  193. which can throw <i>std::bad_alloc </i>exceptions to report memory allocation
  194. errors. These exceptions may be thrown even
  195. though the error condition leading to the exception is not explicitly specified
  196. in the function's &quot;Throws&quot; paragraph.</p>
  197. <p>Nominally non-throwing versions are provided for
  198. <a href="reference.html#Operational-functions">operational functions</a> that
  199. access the external file system, since these are often used
  200. in contexts where error codes may be the preferred way to report an error. Even
  201. the nominally non-throwing versions of functions will throw <i>std::bad_alloc </i>
  202. exceptions to report memory allocation errors. However, functions marked <code>
  203. noexcept</code> never throw exceptions.</p>
  204. <h2><a name="Headers">Headers</a></h2>
  205. <p>The Boost.Filesystem library provides several&nbsp;headers:</p>
  206. <ul>
  207. <li>Header &lt;<a href="../../../boost/filesystem.hpp">boost/filesystem.hpp</a>&gt;
  208. provides access to all features of the library, except file streams.<br>
  209. &nbsp;</li>
  210. <li>Header &lt;<a href="../../../boost/filesystem/fstream.hpp">boost/filesystem<i>/</i>fstream.hpp</a>&gt;
  211. inherits the same components as the C++ Standard
  212. Library's <i>fstream</i> header, but files are identified by <code>const path&amp;</code>
  213. arguments rather that <code>const char*</code> arguments.</li>
  214. </ul>
  215. <h2><a name="Examples">Example programs</a></h2>
  216. <p>See the <a href="tutorial.html">tutorial</a> for example programs.</p>
  217. <h2><a name="Implementation">Implementation</a></h2>
  218. <p>The current implementation supports operating systems which provide
  219. the POSIX or Windows API's.</p>
  220. <p>The library is in regular use on Apple OS X, HP-UX, IBM AIX, Linux,
  221. Microsoft Windows, SGI IRIX, and Sun Solaris operating systems using a variety
  222. of compilers. It is also used by several smart phone operating systems.</p>
  223. <h2><a name="Macros">Macros</a></h2>
  224. <p>Users may defined the following macros if desired. Sensible defaults are
  225. provided, so users can ignore these macros unless they have special needs.</p>
  226. <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
  227. <tr>
  228. <td><b><i>Macro Name</i></b></td>
  229. <td><b><i>Default</i></b></td>
  230. <td><b><i>Effect if defined</i></b></td>
  231. </tr>
  232. <tr>
  233. <td valign="top"><code>BOOST_FILESYSTEM_NO_DEPRECATED</code></td>
  234. <td valign="top">Not defined.</td>
  235. <td valign="top">Deprecated features are excluded from headers.</td>
  236. </tr>
  237. <tr>
  238. <td valign="top"><code>BOOST_FILESYSTEM_DYN_LINK</code></td>
  239. <td valign="top">Defined if <code>BOOST_ALL_DYN_LINK</code> is defined,
  240. otherwise not defined.</td>
  241. <td valign="top">The Boost.Filesystem library is dynamically linked. If not defined,
  242. static linking is assumed.</td>
  243. </tr>
  244. <tr>
  245. <td valign="top"><code>BOOST_FILESYSTEM_NO_LIB</code></td>
  246. <td valign="top">Defined if <code>BOOST_ALL_NO_LIB</code> is defined,
  247. otherwise not defined.</td>
  248. <td valign="top">Boost.Filesystem library does not use the Boost auto-link
  249. facility.</td>
  250. </tr>
  251. </table>
  252. <p>User-defined BOOST_POSIX_API and BOOST_WINDOWS_API macros are no longer
  253. supported.</p>
  254. <h2><a name="Building">Building</a> the object-library</h2>
  255. <p>The object-library will be built automatically if you are using the Boost
  256. build system. See
  257. <a href="../../../more/getting_started.html">Getting Started</a>. It can also be
  258. built manually using a <a href="../build/Jamfile.v2">Jamfile</a>
  259. supplied in directory libs/filesystem/build, or the user can construct an IDE
  260. project or make file which includes the object-library source files.</p>
  261. <p>The object-library source files are
  262. supplied in the <a href="../src">src directory</a>. These source files implement the
  263. library for POSIX or Windows compatible operating systems; no implementation is
  264. supplied for other operating systems. Note that many operating systems not
  265. normally thought of as POSIX systems, such as mainframe legacy
  266. operating systems or embedded operating systems, support POSIX compatible file
  267. systems and so will work with the Filesystem Library.</p>
  268. <p>The object-library can be built for static or dynamic (shared/dll) linking.
  269. This is controlled by the BOOST_ALL_DYN_LINK or BOOST_FILESYSTEM_DYN_LINK
  270. macros. See the <a href="http://www.boost.org/development/separate_compilation.html">Separate
  271. Compilation</a> page for a description of the techniques used.</p>
  272. <h3>Note for <a name="Cgywin">Cygwin</a> users</h3>
  273. <p> <a href="http://www.cygwin.com/">Cygwin</a> version 1.7 or later is
  274. required because only versions of GCC with wide character strings are supported.</p>
  275. <p> The library's implementation code treats Cygwin as a Windows platform, and
  276. thus uses the Windows API and uses Windows path syntax as the native path
  277. syntax.</p>
  278. <h2><a name="Change-history">Version history</a></h2>
  279. <h3>Version 4</h3>
  280. <p><b>Under development </b>- Add support for the
  281. <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4099.html">ISO
  282. C++ File System Technical Specification</a>. The Filesystem TS is based on
  283. Boost.Filesystem Version 3, with only a small number of changes. Most user code
  284. written for Version 3 should work unchanged with Version 4.</p>
  285. <h3>Version 3</h3>
  286. <p>Boost 1.44.0 - June, 2010 - Internationalization via single class <code>path</code>.
  287. More uniform error handling.</p>
  288. <p>Peter Dimov suggested use of a single path class rather than a <code>basic_path</code>
  289. class template. That idea was the basis for the Version 3 redesign.</p>
  290. <p>Thanks for comments from Robert Stewart, Zach Laine, Peter Dimov, Gregory
  291. Peele, Scott McMurray, John Bytheway, Jeff Flinn, Jeffery Bosboom.</p>
  292. <h3>Version 2</h3>
  293. <p>Boost 1.34.0 - May, 2007 - Internationalization via <code>basic_path</code>
  294. template.</p>
  295. <p>So many people have contributed comments and bug reports that it isn't any
  296. longer possible to acknowledge them individually. That said, Peter Dimov and Rob
  297. Stewart need to be specially thanked for their many constructive criticisms and
  298. suggestions. Terence
  299. Wilson and Chris Frey contributed timing programs which helped illuminate
  300. performance issues.</p>
  301. <h3>Version 1</h3>
  302. <p>Boost 1.30.0 - March, 2003 - Initial official Boost release.</p>
  303. <p>The Filesystem Library was designed and implemented by Beman Dawes. The
  304. original <i>directory_iterator</i> and <i>filesystem_error</i> classes were
  305. based on prior work from Dietmar Kuehl, as modified by Jan Langer. Thomas Witt
  306. was a particular help in later stages of initial development. Peter Dimov and
  307. Rob Stewart made many useful suggestions and comments over a long period of
  308. time. Howard Hinnant helped with internationalization issues.</p>
  309. <p>Key <a href="design.htm#Requirements">design requirements</a> and
  310. <a href="design.htm#Realities">design realities</a> were developed during
  311. extensive discussions on the Boost mailing list, followed by comments on the
  312. initial implementation. Numerous helpful comments were then received during the
  313. Formal Review.<p>Participants included
  314. Aaron Brashears,
  315. Alan Bellingham,
  316. Aleksey Gurtovoy,
  317. Alex Rosenberg,
  318. Alisdair Meredith,
  319. Andy Glew,
  320. Anthony Williams,
  321. Baptiste Lepilleur,
  322. Beman Dawes,
  323. Bill Kempf,
  324. Bill Seymour,
  325. Carl Daniel,
  326. Chris Little,
  327. Chuck Allison,
  328. Craig Henderson,
  329. Dan Nuffer,
  330. Dan'l Miller,
  331. Daniel Frey,
  332. Darin Adler,
  333. David Abrahams,
  334. David Held,
  335. Davlet Panech,
  336. Dietmar Kuehl,
  337. Douglas Gregor,
  338. Dylan Nicholson,
  339. Ed Brey,
  340. Eric Jensen,
  341. Eric Woodruff,
  342. Fedder Skovgaard,
  343. Gary Powell,
  344. Gennaro Prota,
  345. Geoff Leyland,
  346. George Heintzelman,
  347. Giovanni Bajo,
  348. Glen Knowles,
  349. Hillel Sims,
  350. Howard Hinnant,
  351. Jaap Suter,
  352. James Dennett,
  353. Jan Langer,
  354. Jani Kajala,
  355. Jason Stewart,
  356. Jeff Garland,
  357. Jens Maurer,
  358. Jesse Jones,
  359. Jim Hyslop,
  360. Joel de Guzman,
  361. Joel Young,
  362. John Levon,
  363. John Maddock,
  364. John Williston,
  365. Jonathan Caves,
  366. Jonathan Biggar,
  367. Jurko,
  368. Justus Schwartz,
  369. Keith Burton,
  370. Ken Hagen,
  371. Kostya Altukhov,
  372. Mark Rodgers,
  373. Martin Schuerch,
  374. Matt Austern,
  375. Matthias Troyer,
  376. Mattias Flodin,
  377. Michiel Salters,
  378. Mickael Pointier,
  379. Misha Bergal,
  380. Neal Becker,
  381. Noel Yap,
  382. Parksie,
  383. Patrick Hartling, Pavel Vozenilek,
  384. Pete Becker,
  385. Peter Dimov,
  386. Rainer Deyke,
  387. Rene Rivera,
  388. Rob Lievaart,
  389. Rob Stewart,
  390. Ron Garcia,
  391. Ross Smith,
  392. Sashan,
  393. Steve Robbins,
  394. Thomas Witt,
  395. Tom Harris,
  396. Toon Knapen,
  397. Victor Wagner,
  398. Vincent Finn,
  399. Vladimir Prus, and
  400. Yitzhak Sapir
  401. <p>A lengthy discussion on the C++ committee's library reflector illuminated the &quot;illusion
  402. of portability&quot; problem, particularly in postings by PJ Plauger and Pete Becker.</p>
  403. <p>Walter Landry provided much help illuminating symbolic link use cases for
  404. version 1.31.0.&nbsp;</p>
  405. <hr>
  406. <p>Revised
  407. <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->25 October, 2015<!--webbot bot="Timestamp" endspan i-checksum="38877" --></p>
  408. <p>&copy; Copyright Beman Dawes, 2002-2005</p>
  409. <p> Use, modification, and distribution are subject to the Boost Software
  410. License, Version 1.0. See <a href="http://www.boost.org/LICENSE_1_0.txt">
  411. www.boost.org/LICENSE_1_0.txt</a></p>
  412. </body>
  413. </html>