Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58766 - in sandbox/filesystem-v3: boost/filesystem libs/filesystem/doc libs/filesystem/src libs/filesystem/test libs/filesystem/test/msvc/filesystem_dll libs/filesystem/test/msvc/operations_unit_test
From: bdawes_at_[hidden]
Date: 2010-01-06 08:25:14


Author: bemandawes
Date: 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
New Revision: 58766
URL: http://svn.boost.org/trac/boost/changeset/58766

Log:
work-in-progress, including adding unique_path
Added:
   sandbox/filesystem-v3/libs/filesystem/src/unique_path.cpp (contents, props changed)
Text files modified:
   sandbox/filesystem-v3/boost/filesystem/operations.hpp | 8 ++
   sandbox/filesystem-v3/boost/filesystem/path.hpp | 68 +----------------------
   sandbox/filesystem-v3/libs/filesystem/doc/do_list.html | 66 ++++++++++++++++++++++-
   sandbox/filesystem-v3/libs/filesystem/doc/faq.htm | 45 +++++++++------
   sandbox/filesystem-v3/libs/filesystem/doc/reference.html | 114 ++++++++++++++++++++++++++++-----------
   sandbox/filesystem-v3/libs/filesystem/doc/v3.html | 4 +
   sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj | 4 +
   sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj | 4 +
   sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp | 14 ++++
   sandbox/filesystem-v3/libs/filesystem/test/operations_unit_test.cpp | 17 +++++
   sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp | 14 ++++
   11 files changed, 237 insertions(+), 121 deletions(-)

Modified: sandbox/filesystem-v3/boost/filesystem/operations.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/operations.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/operations.hpp 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -202,6 +202,8 @@
     space_info space(const path& p, system::error_code* ec=0);
     BOOST_FILESYSTEM_DECL
     path system_complete(const path& p, system::error_code* ec=0);
+ BOOST_FILESYSTEM_DECL
+ path unique_path(const path& p, system::error_code* ec=0);
   } // namespace detail
 
 //--------------------------------------------------------------------------------------//
@@ -450,6 +452,12 @@
   inline
   path system_complete(const path& p, system::error_code& ec)
                                        {return detail::system_complete(p, &ec);}
+ inline
+ path unique_path(const path& p="%%%%-%%%%-%%%%-%%%%")
+ { return detail::unique_path(p); }
+ inline
+ path unique_path(const path& p, system::error_code& ec)
+ { return detail::unique_path(p, &ec); }
 
 //--------------------------------------------------------------------------------------//
 // //

Modified: sandbox/filesystem-v3/boost/filesystem/path.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/path.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/path.hpp 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -12,47 +12,6 @@
 // basename(), extension(), and change_extension() from the original
 // filesystem/convenience.hpp header by Vladimir Prus.
 
-//--------------------------------------------------------------------------------------//
-/*
- TO DO
-
- * Document breaking changes, provide workarounds where possible.
- * Windows, POSIX, conversions for char16_t, char32_t for supporting compilers.
- * Move semantics and other C++0x features.
- * Add Alternate Data Stream test cases. See http://en.wikipedia.org/wiki/NTFS Features.
- * test case: relational on paths differing only in trailing separator. rationale?
- * Behavior of root_path() has been changed. Change needs to be propagated to trunk.
- reference.html#Path-decomposition-table needs rows for //, //netname, //netname/foo
- Make sure current trunk has passing tests for those cases, all decompositions.
- See test_decompositions() in path_unit_test.cpp
- * Document leading //: no longer treated specially.
- * Document behavior of path::replace_extension has change WRT argument w/o a dot.
- * Provide the name check functions for more character types? Templatize?
- * Use BOOST_DELETED, BOOST_DEFAULTED, where appropriate.
- * Add test for scoped_path_locale.
- * Add codepage 936/950/etc test cases.
-
- Design Questions
-
-
- * Is it OK for single-element decomposition functions to return paths? Yes;
- keep the interface simple and usable in generic code at the expense of some
- notational convenience.
- * Are generic versions of string(), native_string() needed? IE:
- template< class T >
- T string(const error_code ec = throws());
- TODO: Yes; all member functions need to be usable in generic code.
- * Assuming generic versions of string(), native_string(), are the w flavors needed?
- No. KISS. basic_string<char> is special because it is the predominent
- use case. w (and other) flavors can be added later.
- * Should UDT's be supported? Yes. Easy to do and pretty harmless.
- * Should path iteration to a separator result in:
- -- the actual separator used
- -- the preferred separator
- -- the generic separator <-- makes it easier to write portable code
- */
-//--------------------------------------------------------------------------------------//
-
 #ifndef BOOST_FILESYSTEM_PATH_HPP
 #define BOOST_FILESYSTEM_PATH_HPP
 
@@ -90,28 +49,7 @@
   //------------------------------------------------------------------------------------//
 
 /*
- FAQ
-
- Why are there no error_code & arguments?
- ----------------------------------------
-
- error_code & arguments add considerably to the surface area of the interface, yet
- appear to be of limited usefulness. They have not been requested by users; the need
- for filesystem error reporting via error_code seems limited to operational failures
- rather than path failures.
-
- error_code & arguments double the number of signatures, since for efficiency the
- use of a default throws() argument is not desirable.
-
- Errors in path conversions only occur if the source and target value types differ AND
- the target encoding can't represent a character present in the source. The only
- commonplace case is when directory iteration on Windows encounters a file name that
- can't be represented in a char encoding.
-
- Workarounds (such as pre-scanning for characters that can't be encoded) appear
- resonable.
-
- Why are there no const codecvt_type & arguments?
+ Why are there no const codecvt_type& arguments?
    ------------------------------------------------
 
    To hold down the size of the class path interface. Per function codecvt facets
@@ -370,7 +308,7 @@
     bool has_filename() const { return !m_path.empty(); }
     bool has_stem() const { return !stem().empty(); }
     bool has_extension() const { return !extension().empty(); }
- bool is_complete() const
+ bool is_absolute() const
     {
 # ifdef BOOST_WINDOWS_PATH
       return has_root_name() && has_root_directory();
@@ -378,6 +316,7 @@
       return has_root_directory();
 # endif
     }
+ bool is_relative() const { return !is_absolute(); }
 
     // ----- imbue -----
 
@@ -412,6 +351,7 @@
     path branch_path() const { return parent_path(); }
     bool has_leaf() const { return !m_path.empty(); }
     bool has_branch_path() const { return !parent_path().empty(); }
+ bool is_complete() const { return is_absolute(); }
 # endif
 
 # if defined(BOOST_FILESYSTEM_DEPRECATED)

Modified: sandbox/filesystem-v3/libs/filesystem/doc/do_list.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/do_list.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/do_list.html 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -6,15 +6,75 @@
 <meta name="ProgId" content="FrontPage.Editor.Document">
 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
 <title>Do List</title>
+<style type="text/css">
+ body { font-family: sans-serif; margin: 1em; }
+ p, td, li, blockquote { font-size: 10pt; }
+ pre { font-size: 9pt; }
+</style>
 </head>
 
 <body>
 
-<h1>Boost.Filesystem Do List</h1>
+<h1>Boost Filesystem Do List</h1>
+
+<h2>Docs</h2>
+<ul>
+ <li><font size="4">Finish Rev 0 of tutorial</font></li>
+ <li>Fix broken links.</li>
+ <li>Review FAQ.</li>
+ <li>Should minimal.css be changed to used relative font sizes? See
+ http://www.w3schools.com/CSS/pr_font_font-size.asp\</li>
+ <li>Document behavior of path::replace_extension has change WRT argument w/o a
+ dot.</li>
+ <li style="font-size: 10pt">Document leading //: no longer treated specially.
+ But is that really correct?</li>
+ <li style="font-size: 10pt">Behavior of root_path() has been changed. Change
+ needs to be propagated to trunk? reference.html#Path-decomposition-table needs
+ rows for //, //netname, //netname/foo Make sure current trunk has passing
+ tests for those cases, all decompositions. See test_decompositions() in
+ path_unit_test.cpp.</li>
+ <li style="font-size: 10pt">Add docs for scoped_path_locale.</li>
+</ul>
+
+<h2>Code</h2>
+<h3>All</h3>
+<ul>
+ <li style="font-size: 10pt">Move semantics.</li>
+ <li style="font-size: 10pt">Use BOOST_DELETED, BOOST_DEFAULTED, where
+ appropriate.</li>
+ <li style="font-size: 10pt">Other C++0x features.</li>
+</ul>
+<h3>Class path</h3>
+<ul>
+ <li>Windows, POSIX, conversions for char16_t, char32_t for C++0x compilers.</li>
+ <li>Add Windows Alternate Data Stream test cases. See http://en.wikipedia.org/wiki/NTFS
+ Features.</li>
+ <li>Add test case: relational operators on paths differing only in trailing
+ separator. Rationale?</li>
+ <li>Provide the name check functions for more character types? Templatize?</li>
+ <li style="font-size: 10pt">Add test for scoped_path_locale.</li>
+ <li style="font-size: 10pt">Add codepage 936/950/etc test cases.</li>
+ <li style="font-size: 10pt">Are generic versions of string(), native_string()
+ needed? IE:<br>
+ template&lt; class T &gt;<br>
+ T string(const error_code ec = throws());<br>
+ TODO: Maybe; all member functions need to be usable in generic code.</li>
+ <li style="font-size: 10pt">Assuming generic versions of string(),
+ native_string(), are the w flavors needed? No. KISS. basic_string&lt;char&gt; is
+ special because it is the predominant use case. w (and other) flavors can be
+ added later.</li>
+ <li style="font-size: 10pt">Should UDT's be supported?</li>
+ <li style="font-size: 10pt">Should path iteration to a separator result in:<br>
+ -- the actual separator used<br>
+ -- the preferred separator<br>
+ -- the generic separator &lt;-- makes it easier to write portable code</li>
+</ul>
+<h3>Operations</h3>
 <ul>
- <li>Rename path::is_complete() -&gt; is_absolute().</li>
+ <li>Would complete(), system_complete() be clearer if renamed absolute(),
+ absolute_system() (or absolute_native())?</li>
 </ul>
 
 </body>
 
-</html>
+</html>
\ No newline at end of file

Modified: sandbox/filesystem-v3/libs/filesystem/doc/faq.htm
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/faq.htm (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/faq.htm 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -31,8 +31,22 @@
   </tr>
 </table>
 
-<h1>
+<h1 dir="ltr">
 Frequently Asked Questions</h1>
+<h2>General questions</h2>
+<p><b>Why not support a concept of specific kinds of file systems, such as posix_file_system or windows_file_system.</b></p>
+<p>Portability is one of the most important requirements for the
+library.&nbsp;Gaining some advantage by using features specific to particular
+operating systems is not a requirement. There doesn't appear to be much need for
+the ability to manipulate, say, a classic Mac OS path while running on an
+OpenVMS machine.</p>
+<p>Furthermore, concepts like &quot;file system&quot;
+are very slippery. What happens when a NTFS or FAT file system is mounted
+in directory on a machine running a POSIX-like operating system, for example?
+Some of the POSIX API's may return very un-POSIX like results.</p>
+
+<h2 dir="ltr">
+Class <code><font size="6">path</font></code> questions </h2>
 <p><b>Why base the generic-path string format on POSIX?</b></p>
 <p>[POSIX-01] is an ISO Standard. It is the basis for the most familiar path-string formats,
 not just for POSIX systems but also for the native Windows format and the
@@ -52,22 +66,15 @@
 Several early versions did require users to identify each path as a file or
 directory path, and this seemed to increase errors and decrease code
 readability. There was no apparent upside benefit.</p>
-<p><b>Why are fully specified paths called <i>complete</i> rather than <i>
-<a name="absolute">absolute</a></i>?</b></p>
-<p>To avoid long-held assumptions (what do you mean, <i>&quot;/foo&quot;</i> isn't
-absolute on some systems?) by programmers used to single-rooted filesystems.
-Using an unfamiliar name for the concept and related functions causes
-programmers to read the specs rather than just assuming the meaning is known.</p>
-<p><b>Why not support a concept of specific kinds of file systems, such as posix_file_system or windows_file_system.</b></p>
-<p>Portability is one of the most important requirements for the
-library.&nbsp;Gaining some advantage by using features specific to particular
-operating systems is not a requirement. There doesn't appear to be much need for
-the ability to manipulate, say, a classic Mac OS path while running on an
-OpenVMS machine.</p>
-<p>Furthermore, concepts like &quot;file system&quot;
-are very slippery. What happens when a NTFS or FAT file system is mounted
-in directory on a machine running a POSIX-like operating system, for example?
-Some of the POSIX API's may return very un-POSIX like results.</p>
+<p><b>Why do path decomposition functions yielding a single element return a
+path rather than a string?</b></p>
+<p>Interface simplicity. If they returned strings, flavors would be needed for
+<code>string</code>, <code>wstring</code>, <code>u16string</code>, <code>
+u32string</code>, and generic strings.</p>
+<p><b>Why don't path member functions have overloads with error_code&amp; arguments?</b></p>
+<p>They have not been requested by users; the need for error reporting via
+error_code seems limited to operations failures rather than path failures.</p>
+<h2>Operations function questions</h2>
 <p><b>Why not supply a 'handle' type, and let the file and directory operations
 traffic in it?</b></p>
 <p>It isn't clear there is any feasible way to meet the &quot;portable script-style
@@ -78,7 +85,7 @@
 style may be strongest for directory iterator value type.&nbsp; (See Jesse Jones' Jan 28,
 2002, Boost postings). However, as class path has evolved, it seems sufficient
 even as the directory iterator value type.</p>
-<p><b>Why are the operations.hpp non-member functions so low-level?</b></p>
+<p><b>Why are the operations functions so low-level?</b></p>
 <p>To provide a toolkit from which higher-level functionality can be created.</p>
 <p>An
 extended attempt to add convenience functions on top of, or as a replacement
@@ -143,7 +150,7 @@
 free functions.</p>
 <hr>
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->18 March, 2008<!--webbot bot="Timestamp" endspan i-checksum="29005" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->03 January, 2010<!--webbot bot="Timestamp" endspan i-checksum="38250" --></p>
 <p>© Copyright Beman Dawes, 2002</p>
 <p> Use, modification, and distribution are subject to the Boost Software
 License, Version 1.0. See <a href="http://www.boost.org/LICENSE_1_0.txt">

Modified: sandbox/filesystem-v3/libs/filesystem/doc/reference.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/reference.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/reference.html 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -165,32 +165,54 @@
 </blockquote>
 <h3><a name="Definitions">Definitions</a></h3>
 <p>The following definitions apply throughout this reference documentation:</p>
-<p><i><a name="File">File</a>: </i>An object that can be written to, or read from, or both. A file
+<p><i><b><a name="File">File</a>:</b> </i>An object that can be written to, or read from, or both. A file
 has certain attributes, including type. Common types of files include regular files
 and directories. Other types of files, such as symbolic links, may be supported by the
 implementation.</p>
-<p><i><a name="File-system">File system</a>:</i> A collection of files and certain of their attributes.</p>
-<p><i><a name="Filename">Filename</a>:</i> The name of a file. The format is as
-specified by the <i>POSIX
-<a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_169">
-Filename</a></i> base definition.</p>
-<p><i><a name="Path">Path</a>:</i> A sequence of elements that identify
-a location within a filesystem. The elements are the <i>root-name</i>, <i>
-root-directory</i>, and each successive <i>filename</i>. See
+<p><b><i><a name="File-system">File system</a>:</i></b> A collection of files and certain of their attributes.</p>
+<p><b><i><a name="Filename">Filename</a>:</i></b> The name of a file. Slash and 0
+characters are not permitted in filenames. Implementations may define additional
+characters or specific names that are not permitted. Filenames <code>.</code>&nbsp;
+and <code>..</code>&nbsp; have special meaning. Implementations may define
+additional filenames that have special meaning.</p>
+<blockquote>
+ <p><i>[Note:</i> Most implementations prohibit the ANSI control characters
+ (0x00-0x31) in filenames.</p>
+ <p>Windows implementations prohibit the characters 0x00-0x31, <code>&quot;</code>,<code>
+ *</code>,<code>&nbsp;:</code>,<code> &lt;</code>,<code> &gt;</code>,<code>&nbsp;?</code>,<code>
+ \</code>,<code> /</code>, and<code> |</code>&nbsp;<i>--end note]</i></p>
+</blockquote>
+<p><b><i><a name="Path">Path</a>:</i></b> A sequence of elements that identify
+a location within a filesystem. The elements are the <i>root-name<sub>opt</sub></i>, <i>
+root-directory<sub>opt</sub></i>, and an optional sequence of <i>filenames</i>. See
 <a href="#Pathname-grammar">Pathname grammar</a>.</p>
-<p><i><a name="Pathname">Pathname</a>: </i>A character string that represents a
+<p><b><i><a name="Absolute-path">Absolute path</a>:</i></b> A path that uniquely
+identifies a file. The format is implementation defined. </p>
+<blockquote>
+ <p><i>[Note:</i> For POSIX-like implementations, including<b> </b>Unix
+ variants, Linux, and Cygwin, only paths
+ that begin with a slash are absolute paths.</p>
+ <p>For Windows-like implementations, including Windows and
+ MinGW, only paths that begin with a drive
+ specifier followed by a slash, or begin with two slashes, are absolute paths.&nbsp;<i>--end
+ note]</i></p>
+</blockquote>
+<p><b><a name="Relative-path">Relative path</a>:</b> A path that only uniquely
+identifies a file when considered relative to some other path. [<i>Note:</i>
+Paths &quot;.&quot; and &quot;..&quot; are considered to be relative paths. <i>--end note</i>]</p>
+<p><i><b><a name="Pathname">Pathname</a>:</b> </i>A character string that represents a
 path.</p>
-<p><i><a name="Link">Link</a>: </i>A directory entry object that associates a
+<p><i><b><a name="Link">Link</a>:</b> </i>A directory entry object that associates a
 filename with a file. On some file systems, several directory entries can
 associate names with the same file.</p>
-<p><i><a name="Hard-link">Hard link</a>:</i> A link to an existing file. Some
+<p><b><i><a name="Hard-link">Hard link</a>:</i></b> A link to an existing file. Some
 file systems support multiple hard links to a file. If the last hard link to a
 file is removed, the file itself is removed.</p>
 <blockquote>
 <p>[<i>Note:</i> A hard link can be thought of as a shared-ownership smart
 pointer to a file.<i> -- end note</i>]<i> </i></p>
 </blockquote>
-<p><i><a name="Symbolic-link">Symbolic link</a>: </i>A type of file with the
+<p><i><a name="Symbolic-link">S<b>ymbolic link</b></a><b>:</b> </i>A type of file with the
 property that when the file is encountered during pathname resolution, a string
 stored by the file is used to modify the pathname resolution.</p>
 <blockquote>
@@ -198,10 +220,10 @@
 If the file pointed to does not exist, the symbolic link is said to be a
 &quot;dangling&quot; symbolic link.<i> -- end note</i>]<i> </i></p>
 </blockquote>
-<p><i><a name="Slash">Slash</a>:</i> The character <tt>'/'</tt>, also known as
+<p><b><i><a name="Slash">Slash</a>:</i></b> The character <tt>'/'</tt>, also known as
 solidus.</p>
-<p><i><a name="Dot">Dot</a>:</i> The character '.', also known as period.</p>
-<p><i><a name="Race-condition">Race condition</a>:</i> The condition that occurs
+<p><b><i><a name="Dot">Dot</a>:</i></b> The character '.', also known as period.</p>
+<p><b><i><a name="Race-condition">Race condition</a>:</i></b> The condition that occurs
 when multiple threads, processes, or computers interleave access and
 modification of
 the same object within a file system.</p>
@@ -401,8 +423,9 @@
 </ul>
 <h3><a name="class-path">Class <code>path</code></a></h3>
 <p>An object of class <code>path</code> represents a path,
-and contains a pathname in the
-native format. Such an object is concerned only with the lexical and syntactic aspects
+and contains a pathname in th<span style="background-color: #FF0000">e
+</span>
+native format<span style="background-color: #FF0000">.</span> Such an object is concerned only with the lexical and syntactic aspects
 of a path. The path does not have to actually exist in the operating system's file
 systems, and may contain pathnames which are not even valid for the current operating
 system. </p>
@@ -771,24 +794,26 @@
 <h4> <code><font size="4">class <a name="path-appends">path</a></font></code><a name="path-appends">
 appends</a></h4>
   <p>The append operations use <code>operator/=</code> to denote their semantic
- effect of appending a native directory separator when needed. The native
+ effect of appending the platform's preferred directory separator when needed. The&nbsp;
+ preferred
   directory separator is implementation-defined.</p>
 <blockquote>
     <p align="left">[<i>Note: </i>For POSIX-like implementations, including<b> </b>
- Unix's, Linux, and
- Cygwin, the native directory separator is a forward slash.</p>
+ Unix variants, Linux, and
+ Cygwin, the preferred directory separator is a
+ single forward slash.</p>
     <p align="left">For Windows-like implementations, including Windows and
- MinGW, the native directory
- separator is a backslash.<i>--end note</i>]</p>
+ MinGW, the preferred directory
+ separator is a single backslash.<i>--end note</i>]</p>
       </blockquote>
 <pre>path&amp; operator/=(const path&amp; p);</pre>
 <blockquote>
   <p><i>Effects:</i></p>
   <blockquote>
- Appends a native directory separator to the contained pathname, unless:<ul>
+ Appends the preferred directory separator to the contained pathname, unless:<ul>
     <li>an added separator
     would be redundant, or</li>
- <li>would change an incomplete path to a complete path, or</li>
+ <li>would change an relative path to an absolute path, or</li>
     <li><code>p.empty()</code>, or</li>
     <li><code>*p.native().cbegin()</code> is a directory separator.</li>
   </ul>
@@ -807,7 +832,7 @@
     <ul>
     <li>an added separator
     would be redundant, or</li>
- <li>would change an incomplete path to a complete path, or</li>
+ <li>would change an relative path to an absoute path, or</li>
     <li><code>p.empty()</code>, or</li>
     <li><code>*p.native().cbegin()</code> is a separator.</li>
   </ul>
@@ -1948,7 +1973,7 @@
 <h4><a name="Function-specifications">Operational function specifications</a></h4>
 <pre>path <a name="complete">complete</a>(const path&amp; p, const path&amp; base, system::error_code&amp; ec);</pre>
 <blockquote>
- <p><i>Effects:</i> Composes a complete path from <code>p</code> and <code>base</code>,
+ <p><i>Effects:</i> Composes an absolute path from <code>p</code> and <code>base</code>,
   using the following rules:</p>
   <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
     <tr>
@@ -2115,7 +2140,7 @@
   system library functions, or by another thread. For a safer alternative,
   see <code>initial_path()</code>. The <code>
   current_path()</code> name was chosen to emphasize that the return is a
- complete path, not just a single directory name. <i>-- end note</i>]</p>
+ path, not just a single directory name. <i>-- end note</i>]</p>
 </blockquote>
 <pre>void current_path(const path&amp; p);
 void current_path(const path&amp; p, system::error_code&amp; ec);</pre>
@@ -2548,7 +2573,7 @@
 </blockquote>
 <blockquote>
       <blockquote>
- <p>[<i>Note:</i> Pathname resolution is complete if <code>p</code> names a symbolic link. <i>--
+ <p>[<i>Note:</i> Pathname resolution terminates if <code>p</code> names a symbolic link. <i>--
     end note</i>]</p>
       </blockquote>
       <p><i>Returns:</i> Same as status(), above,<span style="background-color: #FFFF00">
@@ -2559,15 +2584,12 @@
 <pre>path <a name="system_complete">system_complete</a>(const path&amp; p);
 path <a name="system_complete">system_complete</a>(const path&amp; p, system::error_code&amp; ec);</pre>
 <blockquote>
- <p><i>Effects:</i> Composes a complete path from <code>p</code>, using the
+ <p><i>Effects:</i> Composes an absolute path from <code>p</code>, using the
   same rules used by the operating system to resolve a path passed as the
   filename argument to standard library open functions.</p>
   <p><i>Returns:</i> The composed path.</p>
   <p><i>Postconditions:</i> For the returned path, <code>rp,</code> <code>
   rp.is_absolute()</code> is true.</p>
- <p><i>Throws:</i> As specified in
- <a href="file:///C:/boost/filesystem-v3-sandbox/libs/filesystem/doc/reference.html#Error-reporting">
- Error reporting</a>.</p>
   <p>[<i>Note:</i> For <i>POSIX</i>, <code>system_complete(p)</code> has the same semantics as
   <code>complete(p, current_path())</code>.</p>
   <p><a name="windows_effects">For <i>Windows</i></a>, <code>system_complete(p)</code> has the
@@ -2583,6 +2605,30 @@
   <p>See <a href="#complete_note">
   <i>complete()</i> note</a> for usage suggestions. <i>-- end note</i>]</p>
 </blockquote>
+<pre>path <a name="unique_path">unique_path</a>(const path&amp; model=&quot;%%%%-%%%%-%%%%-%%%%&quot;);
+path unique_path(const path&amp; model, system::error_code&amp; ec);</pre>
+<blockquote>
+ <p>The <code>unique_path</code> function generates a path name suitable for
+ creating temporary files, including directories. The name is based
+ on a model that uses the percent sign character to specify replacement by a
+ random hexadecimal digit. [<i>Note:</i> The more bits of randomness in the
+ generated path name, the less likelihood of prior existence or being guessed.
+ Each replacement hexadecimal digit in the model adds four bits of randomness.
+ The default model thus provides 64 bits of randomness. This is sufficient for
+ most applications. <i>--end note</i>]</p>
+ <p><i>Returns:</i> A path identical to <code>model</code>, except that each
+ occurrence of a percent sign character is replaced by a random hexadecimal
+ digit character in the range 0-9, a-f.</p>
+ <p><i>Throws:</i> As specified in
+ <a href="file:///C:/boost/filesystem-v3-sandbox/libs/filesystem/doc/reference.html#Error-reporting">
+ Error reporting</a>.</p>
+ <p><i>Remarks:</i> Implementations are encouraged to obtain the required
+ 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
+ provided by the operating system. [<i>Note</i>: Such generators may block
+ until sufficient entropy develops. <i>--end note</i>]</p>
+</blockquote>
 <h4><a name="Convenience-functions">Convenience functions</a></h4>
 <table border="1" cellpadding="5" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111">
   <tr>
@@ -3347,7 +3393,7 @@
 <p>Distributed under the Boost Software License, Version 1.0. See
 <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->02 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32136" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->06 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32144" --></p>
 
 </body>
 

Modified: sandbox/filesystem-v3/libs/filesystem/doc/v3.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/v3.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/v3.html 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -52,6 +52,8 @@
     <li><code>read_symlink()</code> function added. Supported on both POSIX and
     Windows.</li>
     <li><code>resize_file()</code> function added. Supported on both POSIX and
+ Windows.</li>
+ <li><code>unique_path()</code> function added. Supported on both POSIX and
     Windows.<br>
 &nbsp;</li>
   </ul>
@@ -108,7 +110,7 @@
 <p>Distributed under the Boost Software License, Version 1.0. See
 <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->02 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32136" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->06 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32144" --></p>
 
 </body>
 

Added: sandbox/filesystem-v3/libs/filesystem/src/unique_path.cpp
==============================================================================
--- (empty file)
+++ sandbox/filesystem-v3/libs/filesystem/src/unique_path.cpp 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -0,0 +1,138 @@
+// filesystem system_crypt_random.cpp ------------------------------------------------//
+
+// Copyright Beman Dawes 2010
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_FILESYSTEM_SOURCE
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/throw_exception.hpp>
+
+# ifdef BOOST_POSIX_API
+# include <fcntl.h>
+# else // BOOST_WINDOWS_API
+# include <windows.h>
+# include <wincrypt.h>
+# endif
+
+namespace {
+
+void fail(int err, boost::system::error_code* ec)
+{
+ if (ec == 0)
+ boost::throw_exception( boost::system::system_error(err,
+ boost::system::system_category,
+ "boost::filesystem::unique_path"));
+
+ ec->assign(err, boost::system::system_category);
+ return;
+}
+
+void system_crypt_random(void* buf, std::size_t len, boost::system::error_code* ec)
+{
+# ifdef BOOST_POSIX_API
+
+ int file = open("/dev/urandom", O_RDONLY);
+ if (file == -1)
+ {
+ file = open("/dev/random", O_RDONLY);
+ if (file == -1)
+ {
+ fail(errno, ec);
+ return;
+ }
+ }
+
+ size_t bytes_read = 0;
+ while (bytes_read < len)
+ {
+ ssize_t n = read(file, buf, len - bytes_read);
+ if (n == -1)
+ {
+ close(file);
+ fail(errno, ec);
+ return;
+ }
+ bytes_read += n;
+ buf = static_cast<char*>(buf) + n;
+ }
+
+ close(file);
+
+# else // BOOST_WINDOWS_API
+
+ HCRYPTPROV handle;
+ int errval = 0;
+
+ if (!::CryptAcquireContext(&handle, 0, 0, PROV_RSA_FULL, 0))
+ {
+ errval = ::GetLastError();
+ if (errval == NTE_BAD_KEYSET)
+ {
+ if (!::CryptAcquireContext(&handle, 0, 0, PROV_RSA_FULL, CRYPT_NEWKEYSET))
+ {
+ errval = ::GetLastError();
+ }
+ else errval = 0;
+ }
+ }
+
+ if (!errval)
+ {
+ BOOL gen_ok = ::CryptGenRandom(handle, len, static_cast<unsigned char*>(buf));
+ if (!gen_ok)
+ errval = ::GetLastError();
+ ::CryptReleaseContext(handle, 0);
+ }
+
+ if (!errval) return;
+
+ fail(errval, ec);
+# endif
+}
+
+} // unnamed namespace
+
+namespace boost { namespace filesystem { namespace detail {
+
+BOOST_FILESYSTEM_DECL
+path unique_path(const path& model, system::error_code* ec)
+{
+ std::wstring s (model.native_wstring()); // std::string ng for MBCS encoded POSIX
+ const wchar_t hex[] = L"0123456789abcdef";
+ const int n_ran = 16;
+ const int max_nibbles = 2 * n_ran; // 4-bits per nibble
+ char ran[n_ran];
+
+ int nibbles_used = max_nibbles;
+ for(std::wstring::size_type i=0; i < s.size(); ++i)
+ {
+ if (s[i] == L'%') // digit request
+ {
+ if (nibbles_used == max_nibbles)
+ {
+ system_crypt_random(ran, sizeof(ran), ec);
+ if (ec != 0 && *ec)
+ return "";
+ nibbles_used = 0;
+ }
+ int c = ran[nibbles_used/2];
+ c >>= 4 * (nibbles_used++ & 1); // if odd, shift right 1 nibble
+ s[i] = hex[c & 0xf]; // convert to hex digit and replace
+ }
+ }
+
+ if (ec != 0) ec->clear();
+
+ return s;
+}
+
+}}}

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -195,6 +195,10 @@
>
                         </File>
                         <File
+ RelativePath="..\..\..\src\unique_path.cpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\src\utf8_codecvt_facet.cpp"
>
                         </File>

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -203,6 +203,10 @@
>
                         </File>
                         <File
+ RelativePath="..\..\..\src\unique_path.cpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\src\utf8_codecvt_facet.cpp"
>
                         </File>

Modified: sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -1172,6 +1172,20 @@
 
 int main(int argc, char* argv[])
 {
+// document state of critical macros
+#ifdef BOOST_POSIX_API
+ std::cout << "BOOST_POSIX_API\n";
+#endif
+#ifdef BOOST_WINDOWS_API
+ std::cout << "BOOST_WINDOWS_API\n";
+#endif
+#ifdef BOOST_POSIX_PATH
+ std::cout << "BOOST_PATH_API\n";
+#endif
+#ifdef BOOST_WINDOWS_PATH
+ std::cout << "BOOST_WINDOWS_PATH\n";
+#endif
+
   if (argc > 1 && *argv[1]=='-' && *(argv[1]+1)=='t') report_throws = true;
   if (argc > 1 && *argv[1]=='-' && *(argv[1]+1)=='x') cleanup = false;
 

Modified: sandbox/filesystem-v3/libs/filesystem/test/operations_unit_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/operations_unit_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/operations_unit_test.cpp 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -150,6 +150,20 @@
 
 int main(int, char* argv[])
 {
+// document state of critical macros
+#ifdef BOOST_POSIX_API
+ cout << "BOOST_POSIX_API\n";
+#endif
+#ifdef BOOST_WINDOWS_API
+ cout << "BOOST_WINDOWS_API\n";
+#endif
+#ifdef BOOST_POSIX_PATH
+ cout << "BOOST_PATH_API\n";
+#endif
+#ifdef BOOST_WINDOWS_PATH
+ cout << "BOOST_WINDOWS_PATH\n";
+#endif
+
   this_file = argv[0];
 
   cout << current_path().string() << std::endl;
@@ -181,6 +195,9 @@
   directory_iterator_test();
   operations_test();
   directory_entry_overload_test();
+
+ std::cout << unique_path() << std::endl;
+ std::cout << unique_path("foo-%%%%%-%%%%%-bar") << std::endl;
   
   return ::boost::report_errors();
 }

Modified: sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp 2010-01-06 08:25:11 EST (Wed, 06 Jan 2010)
@@ -778,6 +778,20 @@
 
 int main(int, char*[])
 {
+// document state of critical macros
+#ifdef BOOST_POSIX_API
+ cout << "BOOST_POSIX_API\n";
+#endif
+#ifdef BOOST_WINDOWS_API
+ cout << "BOOST_WINDOWS_API\n";
+#endif
+#ifdef BOOST_POSIX_PATH
+ cout << "BOOST_PATH_API\n";
+#endif
+#ifdef BOOST_WINDOWS_PATH
+ cout << "BOOST_WINDOWS_PATH\n";
+#endif
+
   test_overloads();
   test_constructors();
   test_assignments();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk