|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56617 - in sandbox/filesystem-v3: boost/filesystem libs/filesystem/doc libs/filesystem/src libs/filesystem/test
From: bdawes_at_[hidden]
Date: 2009-10-06 08:39:10
Author: bemandawes
Date: 2009-10-06 08:39:09 EDT (Tue, 06 Oct 2009)
New Revision: 56617
URL: http://svn.boost.org/trac/boost/changeset/56617
Log:
Filesystem V3: commit work-in-progress before class path error handling rework.
Text files modified:
sandbox/filesystem-v3/boost/filesystem/operations.hpp | 1
sandbox/filesystem-v3/boost/filesystem/path.hpp | 9
sandbox/filesystem-v3/libs/filesystem/doc/reference.html | 926 ++++++++++++++++++---------------------
sandbox/filesystem-v3/libs/filesystem/src/operations.cpp | 8
sandbox/filesystem-v3/libs/filesystem/test/path_test.cpp | 22
5 files changed, 459 insertions(+), 507 deletions(-)
Modified: sandbox/filesystem-v3/boost/filesystem/operations.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/operations.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/operations.hpp 2009-10-06 08:39:09 EDT (Tue, 06 Oct 2009)
@@ -15,7 +15,6 @@
* TODO List
*
* Review all operations.cpp code for race conditions similar to #2925. Fix or document.
-* Scoped enum workaround for file_type.
* Enable all BOOST_FILESYSTEM_NO_DEPRECATED code.
* Vista symlink_status support.
* rename and remove really need to be renamed. If users says "using namespace boost::filesystem"
Modified: sandbox/filesystem-v3/boost/filesystem/path.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/path.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/path.hpp 2009-10-06 08:39:09 EDT (Tue, 06 Oct 2009)
@@ -90,7 +90,7 @@
// filesystem_error is not used because errors are sometimes thrown during
// path construction when there isn't a complete path to include.
- // system_error is not used because most uses will be conversion errors, and
+ // system_error is not used because most uses will be for conversion errors, and
// thus it is useful to include the source string causing the error. Since
// processing source string errors is by its nature type dependent, the
// exception class is templated on the string type.
@@ -314,8 +314,8 @@
// access to the internal representation string is efficient and often convenient,
// but may result in less than fully portable code.
- const string_type & native() const { return m_path; }
- const value_type * c_str() const { return m_path.c_str(); }
+ const string_type & native() const { return m_path; } // Throws: nothing
+ const value_type * c_str() const { return m_path.c_str(); } // Throws: nothing
# ifdef BOOST_WINDOWS_API
@@ -577,7 +577,7 @@
}
inline bool operator==( const path & lhs, const path & rhs ) { return lhs == rhs.c_str(); }
inline bool operator==( const path & lhs, const path::string_type & rhs ) { return lhs == rhs.c_str(); }
- inline bool operator==( const path::string_type & lhs, const path & rhs ) { return rhs == lhs; }
+ inline bool operator==( const path::string_type & lhs, const path & rhs ) { return rhs == lhs.c_str(); }
inline bool operator==( const path::value_type * lhs, const path & rhs ) { return rhs == lhs; }
# else // BOOST_POSIX_API
inline bool operator==( const path & lhs, const path & rhs ) { return lhs.native() == rhs.native(); }
@@ -587,7 +587,6 @@
inline bool operator==( const path::value_type * lhs, const path & rhs ) { return lhs == rhs.native(); }
# endif
-
inline bool operator!=( const path & lhs, const path & rhs ) { return !(lhs == rhs); }
inline void swap( path & lhs, path & rhs ) { lhs.swap( rhs ); }
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 2009-10-06 08:39:09 EDT (Tue, 06 Oct 2009)
@@ -56,10 +56,9 @@
<a href="#Input-conversion">Filename conversion</a><br>
-Requirements </td>
- <td width="35%" valign="top"> Class path (continued)<br>
-
-path constructors<br>
+Requirements <br>
+
+ path constructors<br>
<a href="#path-assignments">path assignments</a><br>
@@ -76,8 +75,7 @@
<a href="#path-non-member-functions">path non-member functions</a><br>
<a href="#path-inserter-extractor">path inserter and extractor</a><span style="background-color: #FFFFFF"><br>
-</span>
-<a href="#Class-template-basic_filesystem_error">Class template
+</span> <a href="#Class-template-basic_filesystem_error">Class template
basic_filesystem_error</a><br>
<a href="#basic_filesystem_error-constructors">basic_filesystem_error
@@ -94,8 +92,7 @@
<a href="#directory_entry-observers">directory_entry observers</a><br>
-directory_entry comparisons</td>
- <td width="89%" valign="top">Filesystem library chapter (continued)<br>
+directory_entry comparisons<br>
<a href="#Class-template-directory_iterator">Class template
directory_iterator</a><br>
@@ -107,18 +104,36 @@
recursive_directory_iterator</a><br>
<a href="#file_status">Class
file_status</a><br>
- <a href="#Non-member-functions">
- Non-member operational functions</a><br>
-
-Status functions<br>
-
-Predicate functions<br>
-
-Attribute functions<br>
-
-Other operations functions<br>
-
-Convenience functions<br>
+ </td>
+ <td width="35%" valign="top"> </td>
+ <td width="89%" valign="top">
+ <a href="#Operational-functions">
+ Operational functions</a><br>
+   complete<br>
+   copy_file<br>
+   create_directories<br>
+   create_directory<br>
+   create_hard_link<br>
+   create_symlink<br>
+   current_path<br>
+   exists<br>
+   equivalent<br>
+   file_size<br>
+   initial_path<br>
+   is_directory<br>
+   is_empty<br>
+   is_other<br>
+   is_regular_file<br>
+   is_symlink<br>
+   last_write_time<br>
+   remove<br>
+   remove_all<br>
+   rename<br>
+   space<br>
+   status<br>
+   status_known<br>
+   symlink_status<br>
+   system_complete<br>
<a href="#header-fstream">Additions
to header <fstream></a><br>
<a href="#Suggestions-for-fstream">Suggestions for <code><fstream></code></a><code><br>
@@ -294,36 +309,27 @@
{
class path;
- template<class String, class Traits>
- void swap(path<String, Traits> & lhs, path<String, Traits> & rhs);
+ void swap(path & lhs, path & rhs);
+
+ bool operator==(const path & lhs, const path & rhs);
+ bool operator!=(const path & lhs, const path & rhs);
+ bool operator< (const path & lhs, const path & rhs);
+ bool operator<=(const path & lhs, const path & rhs);
+ bool operator> (const path & lhs, const path & rhs);
+ bool operator>=(const path & lhs, const path & rhs);
+
+ bool operator/ (const path & lhs, const path & rhs);
+
+ std::ostream & operator<<( std::ostream & os, const path & p );
+ std::wostream & operator<<( std::wostream & os, const path & p );
+ std::istream & operator>>( std::istream & is, path & p );
+ std::wistream & operator>>( std::wistream & is, path & p )
- template<class String, class Traits> bool operator<(<i>a</i> a, <i>b</i> b);
- template<class String, class Traits> bool operator==(<i>a</i> a, <i>b</i> b);
- template<class String, class Traits> bool operator!=(<i>a</i> a, <i>b</i> b);
- template<class String, class Traits> bool operator>(<i>a</i> a, <i>b</i> b);
- template<class String, class Traits> bool operator<=(<i>a</i> a, <i>b</i> b);
- template<class String, class Traits> bool operator>=(<i>a</i> a, <i>b</i> b);
- template<class String, class Traits> bool operator/(<i>a</i> a, <i>b</i> b);
-
- template<class Path>
- basic_ostream<typename Path::string_type::value_type, typename Path::string_type::traits_type> &
- operator<<(basic_ostream<typename Path::string_type::value_type, typename Path::string_type::traits_type>& os, const Path & ph);
-
- template<class Path>
- basic_istream<typename Path::string_type::value_type, typename Path::string_type::traits_type> &
- operator>>(basic_istream<typename Path::string_type::value_type, typename Path::string_type::traits_type>& is, Path & ph);
-
- template<class Path> struct is_path;
-
- template<class Path> struct slash { static const char value = '/'; };
- template<class Path> struct dot { static const char value = '.'; };
-<span style="background-color: #FFFFFF"> template<class Path> struct colon { static const char value = ':'; };</span><span style="background-color: #FFFF00">
-</span>
<span style="background-color: #FFFFFF">class filesystem_error;</span><span style="background-color: #FFFF00">
</span>
class basic_filesystem_error;
- typedef basic_filesystem_error<path> filesystem_error;
+ typedef filesystem_error filesystem_error;
typedef basic_filesystem_error<wpath> wfilesystem_error;
<span style="background-color: #FFFFFF">class directory_entry;
@@ -339,7 +345,7 @@
class file_status;
- <span style="background-color: #FFFFFF">struct space_info // returned by </span>space<span style="background-color: #FFFFFF"> function
+ <span style="background-color: #FFFFFF">struct <a name="space_info">space_info</a> // returned by </span>space<span style="background-color: #FFFFFF"> function
{
uintmax_t capacity;
uintmax_t free;
@@ -353,79 +359,49 @@
};
BOOST_SCOPED_ENUM_END
-</span> // status functions
- file_status status(const path& p,
- system::error_code & ec = throws());
- file_status symlink_status(const path& p,
- system::error_code & ec = throws());
-
- // predicate functions
- bool status_known( file_status s );
- bool exists( file_status s );
- bool is_regular_file( file_status s );
- bool is_directory( file_status s );
- bool is_symlink( file_status s );
- bool is_other( file_status s );
-
- bool exists(const path& p,
- system::error_code & ec = throws());
- bool is_directory(const path& p,
- system::error_code & ec = throws());
- bool is_regular_file(const path& p,
- system::error_code & ec = throws());
- bool is_other(const path& p,
- system::error_code & ec = throws());
- bool is_symlink(const path& p,
- system::error_code & ec = throws());
- bool is_empty(const path& p,
- system::error_code & ec = throws());
-
- bool equivalent(const path& p1, const path& p2, system::error_code & ec = throws());
-
- // attribute functions
- path current_path(system::error_code & ec = throws());
- void current_path(const path& p,
- system::error_code & ec = throws());
- const path& initial_path(system::error_code & ec = throws());
- <span style="background-color: #FFFFFF; ">uintmax_t</span> file_size(const path& p,
- system::error_code & ec = throws());
-<span style="background-color: #FFFFFF"> space_info space(const path& p</span>,
- system::error_code & ec = throws()<span style="background-color: #FFFFFF">);</span><span style="background-color: #FFFF00">
-</span> std::time_t last_write_time(const path& p,
- system::error_code & ec = throws());
- void last_write_time(const path& p, const std::time_t new_time,
- system::error_code & ec = throws());
-
- // operations functions
- bool create_directory(const path& p,
- system::error_code & ec = throws());
- void create_hard_link(const path& old, const path& new_link,
- system::error_code & ec = throws());
-<span style="background-color: #FFFFFF"> void create_symlink(const path& old, const path& new_link</span>,
- system::error_code & ec = throws()<span style="background-color: #FFFFFF">);
-</span> bool <span style="background-color: #FFFF00">remove_path</span>(const path& p,
- system::error_code & ec = throws());
- void <span style="background-color: #FFFF00">rename_path</span>(const path& old, const path& new_p,
- system::error_code & ec = throws());
- void copy_file( const path & from, const path & to,
- BOOST_SCOPED_ENUM(copy_option) option,
- system::error_code & ec = throws() );
- void copy_file( const path & from, const path & to,
- system::error_code & ec = throws() )
- path system_complete(const path& p,
- system::error_code & ec = throws());
-<span style="background-color: #FFFF00"> path </span><span style="background-color: #FFFF00">complete(const</span><span style="background-color: #FFFF00"> path& p,
- const path base=</span><span style="background-color: #FFFF00">initial_path</span><span style="background-color: #FFFF00">());
-</span>
- // convenience functions
- bool create_directories(const path& p);
- typename Path::string_type extension(const path& p);
- typename Path::string_type basename(const path& p);
- template <class Path>
- Path change_extension(const path& p, const typename Path::string_type& new_extension);
+ // operational functions
+
+</span> path complete(const path& p, const path& base, system::error_code& ec=throws());
+ path complete(const path& p, system::error_code& ec=throws());
+ void copy_file(const path & from, const path & to,
+ BOOST_SCOPED_ENUM(copy_option) option, system::error_code& ec=throws());
+ void copy_file(const path & from, const path & to, system::error_code& ec=throws());
+ bool create_directories(const path& p, system::error_code& ec=throws());
+ bool create_directory(const path& p, system::error_code& ec=throws());
+ void create_hard_link(const path& p, const path& new_link, system::error_code& ec=throws());
+<span style="background-color: #FFFFFF"> void create_symlink(const path& </span><span style="background-color: #FFFFFF">p, const path& new_link</span>, system::error_code& ec=throws()<span style="background-color: #FFFFFF">);
+</span> path current_path(system::error_code& ec=throws());
+ void current_path(const path& p, system::error_code& ec=throws());
+ bool exists(file_status s);
+ bool exists(const path& p, system::error_code& ec=throws());
+ bool equivalent(const path& p1, const path& p2, system::error_code& ec=throws());
+ <span style="background-color: #FFFFFF; ">uintmax_t</span> file_size(const path& p, system::error_code& ec=throws());
+ const path& initial_path(system::error_code& ec=throws());
+ bool is_directory(file_status s);
+ bool is_directory(const path& p, system::error_code& ec=throws());
+ bool is_empty(const path& p, system::error_code& ec=throws());
+ bool is_other(file_status s);
+ bool is_other(const path& p, system::error_code& ec=throws());
+ bool is_regular_file(file_status s);
+ bool is_regular_file(const path& p, system::error_code& ec=throws());
+ bool is_symlink(file_status s);
+ bool is_symlink(const path& p, system::error_code& ec=throws());
+ std::time_t last_write_time(const path& p, system::error_code& ec=throws());
+ void last_write_time(const path& p, const std::time_t new_time, system::error_code& ec=throws());
+ bool remove(const path& p, system::error_code& ec=throws());
+ uintmax_t remove_all(const path& p, system::error_code& ec=throws());
+ void rename(const path& from, const path& to, system::error_code& ec=throws());
+<span style="background-color: #FFFFFF"> space_info space(const path& p</span>, system::error_code& ec=throws()<span style="background-color: #FFFFFF">);</span><span style="background-color: #FFFF00">
+</span> file_status status(const path& p, system::error_code& ec=throws());
+ bool status_known(file_status s);
+ file_status symlink_status(const path& p, system::error_code& ec=throws());
+ path system_complete(const path& p, system::error_code& ec=throws());
} // namespace filesystem
} // namespace boost</pre>
+<h3><a name="Error-handling">Error handling</a></h3>
+<p><span style="background-color: #FFFF00">To be supplied. See links from
+Operational functions.</span></p>
<h3><a name="Path-traits">Path traits</a></h3>
<p>This subclause defines requirements on classes representing path behavior
traits, and defines two classes that satisfy those requirements for paths based
@@ -569,8 +545,8 @@
path& operator/=(PathSource const & source);
// modifiers
- <span style="background-color: #FFFFFF">void clear();
- void swap(path & rhs);</span>
+ void clear();
+ void swap(path & rhs);
path& remove_filename();
path& replace_extension(const path & new_extension = path());
@@ -962,10 +938,12 @@
for the host operating system. If the implementation emulates a different
operating system, such as Cygwin's emulation of Windows, the format and encoding
will be that of the emulated operating system. <i>--end note]</i></p>
+<p><i>Throws:</i> nothing.</p>
</blockquote>
<pre>const value_type* c_str() const;</pre>
<blockquote>
-<p>Returns: <code>native().c_str()</code>.</p>
+<p><i>Returns:</i> <code>native().c_str()</code>.</p>
+<p><i>Throws:</i> nothing.</p>
</blockquote>
<pre><i><b>const-string</b></i> native_string() const;</pre>
<blockquote>
@@ -1486,7 +1464,7 @@
the result of calling <code>system_message()</code> with a first argument of
<code>code()</code>. The exact format is unspecified.</p>
<p>The implementation shall supply a specialization <code>template<> const char
-* basic_filesystem_error<path>::what() const</code> that returns a string
+* filesystem_error::what() const</code> that returns a string
containing <code>runtime_error::what(),</code> the result of calling <code>
system_message()</code> with a first argument of <code>code()</code>, and if
non-empty, <code>path1().file_string()</code> and <code>path2.file_string()</code>.
@@ -1948,196 +1926,210 @@
<p><i>Effects:</i> Stores <code>v</code>, replacing the previously stored
value.</p>
</blockquote>
-<h3><a name="Non-member-functions">Non-member operational functions</a></h3>
-<h4><a name="Status-functions">Status functions</a></h4>
-<pre>file_status status(const path& p, error_code& ec);
-file_status <a name="symlink_status">symlink_status</a>(const path& p, error_code& ec);</pre>
-<blockquote>
- <p><i>Returns:</i></p>
- <blockquote>
- For <code>status</code>, determine the attributes
- of
- <code>p</code> as if by<i> POSIX </i> <code>
- stat()</code>,
- for <code>symlink_status</code>, determine the attributes as if by <i>POSIX </i> <code>
- <a href="http://www.opengroup.org/onlinepubs/000095399/functions/lstat.html">
- lstat()</a></code>.<blockquote>
- <p>[<i>Note:</i> For symbolic links, <code>stat()</code> continues
- pathname resolution using the contents of the symbolic link, <code>lstat()</code>
- does not. <i>--
- end note</i>]</p>
- </blockquote>
- <p>If the underlying file system reports an error during attribute determination:</p>
- <ul>
- <li>If the error indicating that <code>p</code> could not be resolved, as
- if by POSIX errors ENOENT or ENOTDIR, call <code>ec.clear()</code> and return <code>
- file_status(not_found_flag)</code>.</li>
- </ul>
- <blockquote>
- <blockquote>
- <p>[<i>Note:</i> The effect of this behavior is to distinguish between
- knowing that p
- does not exist, and not being able to determine the status of p. This
- distinction is important to users. <i>--end note</i>]</p>
- </blockquote>
- </blockquote>
- <ul>
- <li>Otherwise, set ec to the error number reported by the underlying
- implementation API
- and return <code>
- file_status(status_unknown)</code>.</li>
- </ul>
- Otherwise:<ul>
- <li>If the attributes indicate a regular file, as if by <i>POSIX</i> S_ISREG(),
- return <code>
- file_status(regular_file)</code>.</li>
- <li>Else if the attributes indicate a directory, as if by <i>POSIX</i> S_ISDIR(),
- return <code>
- file_status(directory_file)</code>.</li>
- <li>Else if the attributes indicate a symbolic link, as if by <i>POSIX</i> S_ISLNK(),
- return <code>
- file_status(symlink_file)</code>. <i>[Note: </i>Only possible for <code>
- symlink_status</code>. <i>--end note]</i></li>
- <li>Else if the attributes indicate a block special file, as if by <i>POSIX</i> S_ISBLK(),
- return <code>
- file_status(block_file)</code>.</li>
- <li>Else if the attributes indicate a character special file, as if by <i>POSIX</i> S_ISCHR(),
- return <code>
- file_status(character_file)</code>.</li>
- <li>Else if the attributes indicate a fifo or pipe file, as if by <i>POSIX</i> S_ISFIFO(),
- return <code>
- file_status(fifo_file)</code>.</li>
- <li>Else if the attributes indicate a socket, as if by <i>POSIX</i> S_ISSOCK(),
- return <code>
- file_status(socket_file)</code>.</li>
- <li>Else return <code>
- file_status(type_unknown)</code>.</li>
- </ul>
- </blockquote>
-<p>[<i>Note:</i> <code>directory_file</code> implies <code>
-directory_iterator</code> on the file would succeed, and <code>
-regular_file</code> implies appropriate <code><fstream></code> operations would succeed,
-assuming no hardware, permission, access, or race
-condition errors. For <code>regular_file,</code> the converse is not true; lack of
-<code>regular_file</code> does not necessarily imply <code><fstream></code> operations would
-fail on a directory.
-<i>-- end note</i>]</p>
-</blockquote>
-<pre>file_status status(const path& p);</pre>
-<blockquote>
- <p><i>Effects:</i> <code>system_error_code ec;</code><br>
-
- <code>file_status stat(status(p, ec));</code></p>
- <p><i>Throws:</i> <code>basic_filesystem_error<Path></code> if <code>ec
- != 0</code></p>
- <p><i>Returns:</i> <code>stat</code></p>
-</blockquote>
-<pre>file_status symlink_status(const path& p);</pre>
-<blockquote>
- <p><i>Effects:</i> <code>system_error_code ec;</code><br>
-
- <code>file_status stat(symlink_status(p, ec));</code></p>
- <p><i>Throws:</i> <code>basic_filesystem_error<Path></code> if <code>ec
- != 0</code></p>
- <p><i>Returns: </i><code>stat</code></p>
+<h3><a name="Operational-functions">Operational functions</a></h3>
+<p>Operational functions query or modify file system components in external
+storage.</p>
+<blockquote>
+<p>[<i>Note:</i> Because the operational functions are subject to
+race conditions and I/O errors,
+error handling is of particular concern. <i>-- end
+note</i>] </p>
</blockquote>
-<h4><a name="Predicate-functions">Predicate functions</a></h4>
-<pre><span style="background-color: #FFFFFF">bool <a name="status_known">status_known</a>(file_status s);</span></pre>
+<pre>path <a name="complete">complete</a>(const path& p, const path& base, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF">
- <code>s.type() != status_unknown</code></span></p>
+ <p><i>Effects:</i> Composes a complete 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>
+ <td align="center"> </td>
+ <td align="center"><b><code>p.has_root_directory()</code></b></td>
+ <td align="center"><b><code>!p.has_root_directory()</code></b></td>
+ </tr>
+ <tr>
+ <td align="center"><b><code>p.has_root_name()</code></b></td>
+ <td align="center"><code>p</code></td>
+ <td align="center">precondition failure</td>
+ </tr>
+ <tr>
+ <td align="center"><b><code>!p.has_root_name()</code></b></td>
+ <td align="center"><code>base.root_name()<br>
+ / p</code></td>
+ <td align="center"><code>base / p</code></td>
+ </tr>
+ </table>
+ <p><i>Returns:</i> The composed path.</p>
+ <p><i>Postcondition:</i> For the returned path, <code>rp,</code> <code>
+ rp.is_complete()</code> is true.</p>
+ <p><i>Throws: </i> <code>filesystem_error</code>
+ <span style="background-color: #FFFFFF">if </span> <code>
+ <span style="background-color: #FFFFFF">!(base.is_complete() && (p.is_complete() || !p.has_root_name()))</span></code></p>
+ <p>[<i><a name="complete_note">Note</a>:</i> When portable behavior is
+ required, use <i>complete()</i>. When operating system dependent behavior is
+ required, use <i>system_complete()</i>.</p>
+ <p>Portable behavior is useful when dealing with paths created
+ internally within a program, particularly if the program should exhibit the
+ same behavior on all operating systems.</p>
+ <p>Operating system dependent behavior is useful when dealing with
+ paths supplied by user input, reported to program users, or when such behavior
+ is expected by program users. <i>--
+ end note</i>]</p>
</blockquote>
-<pre><span style="background-color: #FFFFFF">bool </span><a name="exists"><span style="background-color: #FFFFFF">exists</span></a><span style="background-color: #FFFFFF">(file_status</span><span style="background-color: #FFFFFF"> s);</span></pre>
+<pre>path complete(const path& p, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF">
- <code>status_known(s) && s.type() != file_not_found</code></span></p>
+<p><i>Returns:</i> <code>path(p, initial_path(), ec)</code>.</p>
</blockquote>
-<pre>bool <a name="exists">exists</a>(const path& p);</pre>
+<pre>void <a name="copy_file">copy_file</a>(const path & from, const path & to,
+ BOOST_SCOPED_ENUM(copy_option) option, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i>Returns:</i> <code>exists( status(p) )</code></p>
+ <p><i>Effects:</i> The contents and attributes of the file <code>from</code>
+ resolves to are copied to the file <code>to</code> resolves to.</p>
+ <p><i>Throws:</i> <code>filesystem_error</code> if <code>
+ from.empty() || to.empty() ||!exists(from) || !is_regular_file(from) ||
+ (option==copy_option::fail_if_exists
+ && exists(to))</code></p>
</blockquote>
-<pre><span style="background-color: #FFFFFF">bool </span><code><span style="background-color: #FFFFFF">is_regular_file</span></code><span style="background-color: #FFFFFF">(file_status</span><span style="background-color: #FFFFFF"> s);</span></pre>
+<pre>void copy_file(const path & from, const path & to, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF">
- <code>s.type() == regular_file</code></span></p>
+ <p><i>Effects: </i><code>copy_file(from, to,
+ copy_option::fail_if_exists, ec)</code>.</p>
+
</blockquote>
-<pre><code>bool is_regular_file(const path& p);</code></pre>
+<pre>bool <a name="create_directories">create_directories</a>(const path& p, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i>Returns:</i> <code>is_regular_file( status(p) )</code></p>
+ <p><i>Requires:</i> <code>p.empty() || <br>
+ forall px: px == p || is_parent(px, p): is_directory(px) || !exists( px )</code>
+ </p>
+ <p><i>Returns:</i> The value of <code>!exists(p)</code> prior to the
+ establishment of the postcondition.</p>
+ <p><i>Postcondition:</i> <code>is_directory(p)</code></p>
+ <p><i>Throws:</i> <code>filesystem_error</code> if<code>
+ exists(p) && !is_directory(p)</code></p>
</blockquote>
-<pre><span style="background-color: #FFFFFF">bool </span><code><span style="background-color: #FFFFFF">is_directory</span></code><span style="background-color: #FFFFFF">(file_status</span><span style="background-color: #FFFFFF"> s);</span></pre>
+<pre>bool <a name="create_directory">create_directory</a>(const path& p, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF"> </span>
- <code><span style="background-color: #FFFFFF">s.type() == directory_file</span></code></p>
+ <p><i>Effects:</i> Attempts to create the directory <code>p</code> resolves to,
+ as if by<i> POSIX </i><code>
+ mkdir()</code> with a second argument of S_IRWXU|S_IRWXG|S_IRWXO. </p>
+ <p><i>Throws:</i> <code>filesystem_error</code> if <i>
+ Effects</i> fails for any reason other than because the directory already exists.</p>
+ <p><i>Returns:</i> True if a new directory was created, otherwise false.</p>
+ <p><i>Postcondition:</i> <code>is_directory(dp)</code></p>
</blockquote>
-<pre><code>bool is_directory(const path& p);</code></pre>
+<pre><span style="background-color: #FFFFFF">void <a name="create_hard_link">create_hard_link</a>(const path& p, const path& new_link, system::error_code& ec=throws());</span></pre>
<blockquote>
- <p><i>Returns:</i> <code>is_directory( status(p) )</code></p>
-</blockquote>
-<pre><span style="background-color: #FFFFFF">bool <a name="exists">is_symlink</a>(file_status s);</span></pre>
+ <p><i><span style="background-color: #FFFFFF">Effects:</span></i><span style="background-color: #FFFFFF"> Establishes the postcondition, as if by
+ </span> <i><span style="background-color: #FFFFFF">POSIX</span></i><span style="background-color: #FFFFFF">
+ </span> <code>
+ <a href="http://www.opengroup.org/onlinepubs/000095399/functions/link.html">
+ <span style="background-color: #FFFFFF">link()</span></a></code><span style="background-color: #FFFFFF">.</span></p>
+ <p><i><span style="background-color: #FFFFFF">Postcondition:</span></i></p>
+ <ul>
+ <li><span style="background-color: #FFFFFF"> </span><code><span style="background-color: #FFFFFF">exists(p) &&
+ exists(new_link) && equivalent(p,
+ new_link)</span></code></li>
+ <li><span style="background-color: #FFFFFF">The contents of the file or directory
+ </span> <code><span style="background-color: #FFFFFF">p</span></code><span style="background-color: #FFFFFF"> resolves to are unchanged.</span></li>
+ </ul>
+ <p><span style="background-color: #FFFFFF">[</span><i><span style="background-color: #FFFFFF">Note:</span></i><span style="background-color: #FFFFFF">
+ Some <b>operating systems</b> do not support hard links at all or support
+ them only for regular files. Some file systems limit the number of links per
+ file.
+ Some <b>file systems</b> do not
+ support
+ hard links regardless of the operating system - the FAT system used on floppy discs, memory cards and flash
+ drives,
+ for example. Thus hard links should only be used if these situations are not
+ concerns, or if workarounds are provided. </span> <i><span style="background-color: #FFFFFF">-- end note</span></i><span style="background-color: #FFFFFF">]</span></p>
+ </blockquote>
+<pre><span style="background-color: #FFFFFF">void <a name="create_symlink">create_symlink</a>(const path& p, const path& new_link, system::error_code& ec=throws());</span></pre>
+<blockquote style="font-size: 10pt">
+ <p style="font-size: 10pt"><i><span style="background-color: #FFFFFF">Effects:</span></i><span style="background-color: #FFFFFF">
+ Establishes the postcondition, as if by </span><i>
+ <span style="background-color: #FFFFFF">POSIX</span></i><span style="background-color: #FFFFFF">
+ </span><code><span style="background-color: #FFFFFF">
+ <a href="http://www.opengroup.org/onlinepubs/000095399/functions/symlink.html">
+ symlink()</a></span></code><span style="background-color: #FFFFFF">.</span></p>
+ <p style="font-size: 10pt"><span style="background-color: #FFFFFF"><i>
+ Postcondition:</i> <code>new_link</code> resolves to a symbolic link file that
+ contains an unspecified representation of <code>p</code>.</span></p>
+ <p><span style="background-color: #FFFFFF">[</span><i><span style="background-color: #FFFFFF">Note:</span></i><span style="background-color: #FFFFFF">
+ Some <b>operating systems</b> do not support symbolic links at all or support
+ them only for regular files.
+ Some <b>file systems</b> do not
+ support
+ symbolic links regardless of the operating system - the FAT system used on floppy discs, memory cards and flash
+ drives,
+ for example. Thus symbolic links should only be used if these situations are
+ not concerns, or if workarounds are provided. </span> <i><span style="background-color: #FFFFFF">-- end note</span></i><span style="background-color: #FFFFFF">]</span></p>
+ </blockquote>
+<pre>path <a name="current_path">current_path</a>(system::error_code& ec=throws());</pre>
<blockquote>
- <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF"> </span>
- <code><span style="background-color: #FFFFFF">s.type() == symlink_file</span></code></p>
+ <p><i>Returns:</i> The current working directory path, as if by <i>POSIX</i>
+ <a href="http://www.opengroup.org/onlinepubs/000095399/functions/getcwd.html">
+ <code>getcwd()</code></a>.</p>
+ <p><i>Postcondition:</i> <code>current_path().is_complete()</code></p>
+ <p>[<i>Note:</i> The current path as returned by many operating systems is a
+ dangerous global variable. It may be changed unexpectedly by a third-party or
+ 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>
</blockquote>
-<pre><code>bool is_symlink(const path& p);</code></pre>
+<pre>void current_path(const path& p, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i>Returns:</i> <code>is_symlink( symlink_status(p) )</code></p>
+<p><i>Postcondition:</i> <code>equivalent(p, current_path())</code>.</p>
</blockquote>
-<pre><span style="background-color: #FFFFFF">bool <a name="exists">is_other</a>(file_status s);</span></pre>
+<pre><span style="background-color: #FFFFFF">bool <a name="exists">exists</a>(file_status s);</span></pre>
<blockquote>
<p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF">
- <code>return exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s)</code></span></p>
- <p><span style="background-color: #FFFFFF">[<i>Note: </i>The specification of
- <code>is_other()</code> will remain unchanged even if additional <code>is_xxx()</code>
- functions are added in the future. <i>-- end note</i>]</span></p>
+ <code>status_known(s) && s.type() != file_not_found</code></span></p>
</blockquote>
-<pre><code>bool is_other(const path& p);</code></pre>
+<pre>bool <a name="exists">exists</a>(const path& p, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i>Returns:</i> <code>is_other( status(p) )</code></p>
+ <p><i>Returns:</i> <code>exists( status(p, ec) )</code></p>
</blockquote>
-<pre><code>bool <span style="background-color: #FFFFFF; text-decoration:underline">is_</span>empty(const path& p);</code></pre>
-<blockquote>
- <p><i>Effects:</i> Determines <code>file_status s</code>, as if by <code>
- status(p)</code>.</p>
- <p><i>Throws:</i> <code>basic_filesystem_error<Path></code> if <code>!exist(s) ||
- is_other(s)</code>.</p>
- <p><i>Returns:</i> <code>is_directory(s)<br>
- ?
- directory_iterator<Path>(p) == directory_iterator<Path>()<br>
- : file_size(p) == 0;</code></p>
+<pre><code>bool <a name="equivalent">equivalent</a>(const path& p1, const path& p2, system::error_code& ec=throws());</code></pre>
+<blockquote style="font-size: 10pt">
+ <p style="font-size: 10pt"><i>Effects:</i> Determines <code>file_status s1</code>
+ and <code>s2</code>, as if by <code>status(p1)</code> and <code>status(p2)</code>,
+ respectively.</p>
+ <p style="font-size: 10pt"><i>Throws:</i> <code>filesystem_error</code><span style="background-color: #FFFFFF">
+ </span>if <code>(!exists(s1) && !exists(s2)) || (is_other(s1) && is_other(s2))</code>.</p>
+ <p style="font-size: 10pt"><i>Returns:</i> <code>true</code>, if <code>sf1 ==
+ sf2</code> and <code>p1</code> and <code>p2</code> resolve to the same file
+ system entity, else <code>false</code>.</p>
+ <p style="font-size: 10pt">Two paths are considered to resolve to the same
+ file system entity if two candidate entities reside on the same device at the
+ same location. This is determined as if by the values of the <i>POSIX</i>
+ <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
+ and equal <code>st_ino</code> values.</p>
+ <p style="font-size: 10pt">[<i>Note:</i> <i>POSIX</i> requires that <i>"st_dev</i>
+ must be unique within a Local Area Network". Conservative <i>POSIX</i>
+ 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>,
+ and consider "same" 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>
</blockquote>
-<pre><code>bool <a name="equivalent">equivalent</a>(const path& p1, const path& p2);</code></pre>
+<pre><span style="background-color: #FFFFFF; ">uintmax_t</span> <a name="file_size">file_size</a>(const path& p, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i>Effects:</i> Determines <code>file_status s1</code> and <code>s2</code>,
- as if by <code>status(p1)</code> and <code>status(p2)</code>,
- respectively.</p>
- <p><i>Throws:</i> <code>basic_filesystem_error<path></code><span style="background-color: #FFFFFF"> </span>
- if <code>(!exists(s1) && !exists(s2)) || (is_other(s1) &&
- is_other(s2))</code>.</p>
- <p><i>Returns:</i> <code>true</code>, if <code>sf1 == sf2</code> and <code>p1</code> and <code>p2</code>
- resolve to the same file system entity, else <code>false</code>.</p>
- <p>Two paths are considered to resolve to
- the same file system entity if two candidate entities reside on the same
- device at the same location. This is determined as if by the values of the <i>POSIX</i> <code>
- stat</code>
- structure<code>,</code> obtained as if by <code>
- stat()</code> for the two paths, having equal
- <code>st_dev</code> values and equal <code>st_ino</code> values.</p>
- <p>[<i>Note:</i> <i>POSIX</i> requires that <i>"st_dev</i> must be unique
- within a Local Area Network". Conservative <i>POSIX</i> 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>, and consider "same" 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>
-</blockquote>
-<h4><a name="Attribute-functions">Attribute functions</a></h4>
-<p>[<i>Note:</i> A strictly limited number of attribute functions are provided
-because few file system attributes are portable. Even the functions provided will be impossible to implement on some file
-systems. <i>--end note</i>.]</p>
-<pre>const path <a name="initial_path">initial_path</a>();</pre>
+ <p><i>Returns:</i> The size
+ <span style="background-color: #FFFFFF; ">in bytes</span>
+ of the file <code>p</code> resolves to, determined as if by the value of
+ the <i>POSIX</i> <code>
+ stat</code> structure member <code>st_size</code>
+ obtained as if by <i>POSIX</i> <code>
+ stat()</code>.</p>
+ <p style="font-size: 10pt"><i>Throws:</i> <code>filesystem_error</code><span style="background-color: #FFFFFF">
+ </span>if <code>!exists(p) || !is_regular_file(p)</code>.</p>
+</blockquote>
+<pre>const path& <a name="initial_path">initial_path</a>(system::error_code& ec=throws());</pre>
<blockquote>
<p><i>Returns:</i> <code>current_path()</code> at the time of entry to <code>
main()</code>.</p>
@@ -2152,49 +2144,57 @@
encouraged to call it immediately on entrance to <code>main()</code> so that
they will work correctly with such partial implementations. <i>--end note</i>]</p>
</blockquote>
-<pre>path current_path();</pre>
+<pre><span style="background-color: #FFFFFF">bool </span><code><span style="background-color: #FFFFFF"><a name="is_directory">is_directory</a></span></code><span style="background-color: #FFFFFF">(file_status s);</span></pre>
<blockquote>
- <p><i>Returns:</i> The current path, as if by <i>POSIX</i>
- <a href="http://www.opengroup.org/onlinepubs/000095399/functions/getcwd.html">
- <code>getcwd()</code></a>.</p>
- <p><i>Postcondition:</i> <code>current_path().is_complete()</code></p>
- <p>[<i>Note:</i> The current path as returned by many operating systems is a
- dangerous global variable. It may be changed unexpectedly by a third-party or
- system library functions, or by another thread. Although dangerous, the
- function is useful in dealing with other libraries.. 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>-- </i><i>end note</i>]</p>
+ <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF"> </span>
+ <code><span style="background-color: #FFFFFF">s.type() == directory_file</span></code></p>
</blockquote>
-<pre>void current_path(const path& p);</pre>
+<pre><code>bool is_directory(const path& p, system::error_code& ec=throws());</code></pre>
<blockquote>
-<p><i>Postcondition:</i> equivalent( p, current_path() );</p>
+ <p><i>Returns:</i> <code>is_directory( status(p, ec) )</code></p>
</blockquote>
-<pre><span style="background-color: #FFFFFF; ">uintmax_t</span> file_size(const path& p);</pre>
+<pre><code>bool <span style="background-color: #FFFFFF; text-decoration:underline"><a name="is_empty">is_</a></span><a name="is_empty">empty</a>(const path& p, system::error_code& ec=throws());</code></pre>
<blockquote>
- <p><i>Returns:</i> The size
- <span style="background-color: #FFFFFF; ">in bytes</span>
- of the file <code>p</code> resolves to, determined as if by the value of
- the <i>POSIX</i> <code>
- stat</code> structure member <code>st_size</code>
- obtained as if by <i>POSIX</i> <code>
- stat()</code>.</p>
+ <p><i>Effects:</i> Determines <code>file_status s</code>, as if by <code>
+ status(p, ec)</code>.</p>
+ <p><i>Returns:</i> <code>is_directory(s)<br>
+ ?
+ directory_iterator(p) == directory_iterator()<br>
+ : file_size(p) == 0;</code></p>
+ <p><i>Throws:</i> <code>filesystem_error</code> if <code>!exist(s) ||
+ is_other(s)</code>.</p>
</blockquote>
-<pre><span style="background-color: #FFFFFF">space_info space(const path& p);</span></pre>
+<pre><span style="background-color: #FFFFFF">bool <a name="is_other">is_other</a>(file_status s);</span></pre>
<blockquote>
- <p><span style="background-color: #FFFFFF"><i>Returns:</i> A <code>space_info</code>
- object. The value of the <code>space_info</code> object is determined as if by
- using </span> <i><span style="background-color: #FFFFFF">POSIX</span></i><span style="background-color: #FFFFFF"> <code>
- <a href="http://www.opengroup.org/onlinepubs/000095399/functions/statvfs.html" style="text-decoration: none">
- statvfs()</a></code> to obtain a <i>POSIX</i> struct <code>
- <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/statvfs.h.html" style="text-decoration: none">
- statvfs</a></code>, and then multiplying its <code>f_blocks</code>, <code>
- f_bfree</code>, and <code>f_bavail</code> members by its <code>f_frsize</code>
- member, and assigning the results to the <code>capacity</code>, <code>free</code>,
- and <code>available</code> members respectively. Any members for which the
- value cannot be determined shall be set to -1.</span></p>
+ <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF">
+ <code>return exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s)</code></span></p>
+ <p><span style="background-color: #FFFFFF">[<i>Note: </i>The specification of
+ <code>is_other()</code> will remain unchanged even if additional <code>is_xxx()</code>
+ functions are added in the future. <i>-- end note</i>]</span></p>
+</blockquote>
+<pre><code>bool is_other(const path& p, system::error_code& ec=throws());</code></pre>
+<blockquote>
+ <p><i>Returns:</i> <code>is_other( status(p, ec) )</code></p>
+</blockquote>
+<pre><span style="background-color: #FFFFFF">bool </span><code><span style="background-color: #FFFFFF"><a name="is_regular_file">is_regular_file</a></span></code><span style="background-color: #FFFFFF">(file_status s);</span></pre>
+<blockquote>
+ <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF">
+ <code>s.type() == regular_file</code></span></p>
+</blockquote>
+<pre><code>bool is_regular_file(const path& p, system::error_code& ec=throws());</code></pre>
+<blockquote>
+ <p><i>Returns:</i> <code>is_regular_file( status(p, ec) )</code></p>
+</blockquote>
+<pre><span style="background-color: #FFFFFF">bool <a name="is_symlink">is_symlink</a>(file_status s);</span></pre>
+<blockquote>
+ <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF"> </span>
+ <code><span style="background-color: #FFFFFF">s.type() == symlink_file</span></code></p>
</blockquote>
-<pre>std::time_t last_write_time(const path& p);</pre>
+<pre><code>bool is_symlink(const path& p, system::error_code& ec=throws());</code></pre>
+<blockquote>
+ <p><i>Returns:</i> <code>is_symlink( symlink_status(p, ec) )</code></p>
+</blockquote>
+<pre>std::time_t <a name="last_write_time">last_write_time</a>(const path& p<code>, system::error_code& ec=throws()</code>);</pre>
<blockquote>
<p><i>Returns:</i> The time of last data modification of <code>p</code>, determined as if by the
value of the <i>POSIX</i> <code>
@@ -2202,7 +2202,7 @@
as if by <i>POSIX</i> <code>
<a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html">stat()</a></code>.</p>
</blockquote>
-<pre>void last_write_time(const path& p, const std::time_t new_time);</pre>
+<pre>void last_write_time(const path& p, const std::time_t new_time<code>, system::error_code& ec=throws()</code>);</pre>
<blockquote>
<p><i>Effects:</i> Sets the time of last data modification of the file
resolved to by <code>p</code>
@@ -2211,121 +2211,23 @@
followed by <i>POSIX</i>
<a href="http://www.opengroup.org/onlinepubs/000095399/functions/utime.html">
<code>utime()</code></a>.</p>
- <p>[<i>Note:</i> The apparent postcondition <code>last_write_time(p) ==
- new_time</code> is not specified since it would not hold for many file systems
- due to coarse time mechanism granularity. <i>-- end note</i>]</p>
+ <p>[<i>Note:</i> A postcondition of <code>last_write_time(p) ==
+ new_time</code> is not specified since it would not hold for file systems
+ with coarse time mechanism granularity. <i>-- end note</i>]</p>
</blockquote>
-<h4>Other o<a name="Operations-functions">perations functions</a></h4>
-<pre>bool create_directory(const path dp);</pre>
-<blockquote>
- <p><i>Effects:</i> Attempts to create the directory <code>dp</code> resolves to,
- as if by<i> POSIX </i><code>
- mkdir()</code> with a second argument of S_IRWXU|S_IRWXG|S_IRWXO. </p>
- <p><i>Throws:</i> <code>basic_filesystem_error<Path></code> if <i>
- Effects</i> fails for any reason other than because the directory already exists.</p>
- <p><i>Returns:</i> True if a new directory was created, otherwise false.</p>
- <p><i>Postcondition:</i> <code>is_directory(dp)</code></p>
-</blockquote>
-<pre><span style="background-color: #FFFFFF">void create_hard_link(const path& to_p, const path& from_p, error_code& ec);</span></pre>
-<blockquote>
- <p><i><span style="background-color: #FFFFFF">Requires:</span></i><span style="background-color: #FFFFFF">
- </span> <code><span style="background-color: #FFFFFF">path::external_string_type</span></code><span style="background-color: #FFFFFF"> and
- </span> <code>
- <span style="background-color: #FFFFFF">path::external_string_type</span></code><span style="background-color: #FFFFFF"> are the same type.</span></p>
- <p><i><span style="background-color: #FFFFFF">Effects:</span></i><span style="background-color: #FFFFFF"> Establishes the postcondition, as if by
- </span> <i><span style="background-color: #FFFFFF">POSIX</span></i><span style="background-color: #FFFFFF">
- </span> <code>
- <a href="http://www.opengroup.org/onlinepubs/000095399/functions/link.html">
- <span style="background-color: #FFFFFF">link()</span></a></code><span style="background-color: #FFFFFF">.</span></p>
- <p><i><span style="background-color: #FFFFFF">Postcondition:</span></i></p>
- <ul>
- <li><span style="background-color: #FFFFFF"> </span><code><span style="background-color: #FFFFFF">exists(to_p) && exists(from_p) && equivalent(to_p,
- from_p)</span></code></li>
- <li><span style="background-color: #FFFFFF">The contents of the file or directory
- </span> <code><span style="background-color: #FFFFFF">to_p</span></code><span style="background-color: #FFFFFF"> resolves to are unchanged.</span></li>
- </ul>
- <p><span style="background-color: #FFFFFF">[</span><i><span style="background-color: #FFFFFF">Note:</span></i><span style="background-color: #FFFFFF">
- Some operating systems do not support hard links or support
- them only for regular files. Some operating systems limit the number of links per
- file.
- Some file systems that do not
- support
- hard links - the FAT system used on floppy discs, memory cards and flash
- drives,
- for example. Thus hard links should be avoided if wide portability is
- a concern. </span> <i><span style="background-color: #FFFFFF">-- end note</span></i><span style="background-color: #FFFFFF">]</span></p>
- </blockquote>
-<pre><span style="background-color: #FFFFFF">void create_hard_link(const path& to_p, const path& from_p);</span></pre>
-<blockquote>
- <p><i><span style="background-color: #FFFFFF">Requires:</span></i><span style="background-color: #FFFFFF">
- </span> <code><span style="background-color: #FFFFFF">path::external_string_type</span></code><span style="background-color: #FFFFFF"> and
- </span> <code>
- <span style="background-color: #FFFFFF">path::external_string_type</span></code><span style="background-color: #FFFFFF"> are the same type.</span></p>
- <p><i><span style="background-color: #FFFFFF">Effects:</span></i><span style="background-color: #FFFFFF">
- As if <code>system_error_code ec( create_hard_link( to_p, from_p ) );</code></span></p>
- <p><span style="font-style: italic; background-color: #FFFFFF">Throws:</span><span style="background-color: #FFFFFF">
- </span> <code>basic_filesystem_error<path, path></code><span style="background-color: #FFFFFF">
- if <code>ec</code> is not zero.</span></p>
- </blockquote>
-<pre><span style="background-color: #FFFFFF">void create_symlink(const path& to_p, const path& from_p, error_code& ec);</span></pre>
-<blockquote>
- <p><i><span style="background-color: #FFFFFF">Requires:</span></i><span style="background-color: #FFFFFF">
- </span> <code><span style="background-color: #FFFFFF">path::external_string_type</span></code><span style="background-color: #FFFFFF"> and
- </span> <code>
- <span style="background-color: #FFFFFF">path::external_string_type</span></code><span style="background-color: #FFFFFF"> are the same type.</span></p>
- <p><i><span style="background-color: #FFFFFF">Effects:</span></i><span style="background-color: #FFFFFF"> Establishes the postcondition, as if by
- </span> <i><span style="background-color: #FFFFFF">POSIX</span></i><span style="background-color: #FFFFFF">
- </span> <code>
- <span style="background-color: #FFFFFF">
- <a href="http://www.opengroup.org/onlinepubs/000095399/functions/symlink.html">
- symlink()</a></span></code><span style="background-color: #FFFFFF">.</span></p>
- <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF"> If the
- postcondition cannot be established, a system error code
- indicating the reason for the failure, otherwise 0.</span></p>
- <p><span style="background-color: #FFFFFF"><i>Postcondition:</i> <code>from_p</code>
- resolves to a symbolic link file that contains an unspecified representation
- of <code>to_p</code>.</span></p>
- <p><span style="background-color: #FFFFFF">[</span><i><span style="background-color: #FFFFFF">Note:</span></i><span style="background-color: #FFFFFF">
- Some operating systems do not support symbolic links at all or support
- them only for regular files. Thus symbolic links should be avoided if code portability is
- a concern. </span> <i><span style="background-color: #FFFFFF">-- end note</span></i><span style="background-color: #FFFFFF">]</span></p>
- </blockquote>
-<pre><span style="background-color: #FFFFFF">void create_symlink(const path& to_p, const path& from_p);</span></pre>
+<pre>bool <a name="remove">remove</a>(const path& p, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i><span style="background-color: #FFFFFF">Requires:</span></i><span style="background-color: #FFFFFF">
- </span> <code><span style="background-color: #FFFFFF">path::external_string_type</span></code><span style="background-color: #FFFFFF"> and
- </span> <code>
- <span style="background-color: #FFFFFF">path::external_string_type</span></code><span style="background-color: #FFFFFF"> are the same type.</span></p>
- <p><i><span style="background-color: #FFFFFF">Effects:</span></i><span style="background-color: #FFFFFF">
- As if <code>system_error_code ec( create_symlink( to_p, from_p ) );</code></span></p>
- <p><span style="font-style: italic; background-color: #FFFFFF">Throws:</span><span style="background-color: #FFFFFF">
- </span> <code>basic_filesystem_error<path, path></code><span style="background-color: #FFFFFF">
- if <code>ec</code> is not zero.</span></p>
- </blockquote>
-<pre>void remove(const path& p, system::error_code & ec = <i>singular</i> );</pre>
-<blockquote>
- <p><i>Effects:</i> Removes the file <code>p</code>,
+ <p><i>Remarks:</i> If <code>exists(symlink_status(p,ec))</code>, it is
+ removed
as if by<i> POSIX </i><code>
- remove()</code>.
- If no error is reported by the underlying removal implementation or if <code>
- status(p).type() == file_not_found</code>, then:</p>
- <ul>
- <li>if <code>ec != </code><i><code>singular</code></i>, then <code>ec.clear()</code>.</li>
- </ul>
- <p>Otherwise,</p>
- <ul>
- <li>if <code>ec != </code><i><code>singular</code></i>, then set <code>ec</code>
- to represent the error.</li>
- <li>otherwise, throw <code>basic_filesystem_error<Path></code> to represent
- the error.if <code>ec != </code><i><code>singular</code></i>, then <code>
- ec.clear()</code></li>
- </ul>
- <p><i>Postcondition:</i> <code>!exists(p)</code></p>
- <p><i>Throws:</i> See <i>Effects</i>.</p>
+ remove()</code>.</p>
+ <p><i>Postcondition:</i> <code>!exists(symlink_status(p))</code>.</p>
+ <p><i>Returns:</i> <code>false</code> if p did not exist in the first
+ place, otherwise <code>true</code>.</p>
<p>[<i>Note:</i> A symbolic link is itself removed, rather than the file it
resolves to being removed. <i>-- end note</i>]</p>
</blockquote>
-<pre>unsigned long remove_all(const path& p);</pre>
+<pre>uintmax_t <a name="remove_all">remove_all</a>(const path& p, system::error_code& ec=throws());</pre>
<blockquote>
<p><i>Effects:</i> Recursively deletes the contents of p if it exists,
then deletes file <code>p</code> itself,
@@ -2336,10 +2238,8 @@
<p>[<i>Note:</i> A symbolic link is itself removed, rather than the file it
resolves to being removed. <i>-- end note</i>]</p>
</blockquote>
-<pre>template <class path, class path> void rename(const path& from_p, const path& to_p);</pre>
+<pre>void <a name="rename">rename</a>(const path& from, const path& to, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i>Requires:</i> <code>path::external_string_type</code> and <code>
- path::external_string_type</code> are the same type. </p>
<p><i>Effects:</i> Renames <code>from_p</code> to <code>to_p</code>, as if by
<i>POSIX</i> <code>
<a href="http://www.opengroup.org/onlinepubs/000095399/functions/rename.html">
@@ -2352,64 +2252,107 @@
existing file, it is removed. A symbolic link is itself renamed, rather than
the file it resolves to being renamed. <i>-- end note</i>]</p>
</blockquote>
-<pre>void copy_file(const path & from, const path & to,
- BOOST_SCOPED_ENUM(copy_option) option,
- system::error_code & ec = throws());</pre>
+<pre><span style="background-color: #FFFFFF">space_info <a name="space">space</a>(const path& p</span>, system::error_code& ec=throws()<span style="background-color: #FFFFFF">);</span></pre>
<blockquote>
- <p><i>Effects:</i> The contents and attributes of the file <code>from</code>
- resolves to are copied to the file <code>to</code> resolves to.</p>
- <p><i>Throws:</i> <code>basic_filesystem_error<Path></code> if <code>
- from.empty() || to.empty() ||!exists(from) || !is_regular_file(from) ||
- (option==copy_option::fail_if_exists
- && exists(to))</code></p>
+ <p><span style="background-color: #FFFFFF"><i>Returns:</i> An object of type <code>
+ space_info</code>. The value of the <code>space_info</code> object is determined as if by
+ using </span> <i><span style="background-color: #FFFFFF">POSIX</span></i><span style="background-color: #FFFFFF"> <code>
+ <a href="http://www.opengroup.org/onlinepubs/000095399/functions/statvfs.html" style="text-decoration: none">
+ statvfs()</a></code> to obtain a <i>POSIX</i> struct <code>
+ <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/statvfs.h.html" style="text-decoration: none">
+ statvfs</a></code>, and then multiplying its <code>f_blocks</code>, <code>
+ f_bfree</code>, and <code>f_bavail</code> members by its <code>f_frsize</code>
+ member, and assigning the results to the <code>capacity</code>, <code>free</code>,
+ and <code>available</code> members respectively. Any members for which the
+ value cannot be determined shall be set to -1.</span></p>
</blockquote>
-<pre>void copy_file(const path & from, const path & to,
- system::error_code & ec = throws());</pre>
+<pre>file_status <a name="status">status</a>(const path& p, system::error_code& ec=throws());
+file_status symlink_status(const path& p, system::error_code& ec=throws());</pre>
<blockquote>
- <p><i>Effects:</i><code>copy_file(from, to,
- copy_option::fail_if_exists, ec)</code>.</p>
-
+ <p><i>Returns:</i></p>
+ <blockquote>
+ <p>For <code>status</code>, determine the attributes
+ of
+ <code>p</code> as if by<i> POSIX </i> <code>
+ stat()</code>;
+ for <code>symlink_status</code>, determine the attributes as if by <i>POSIX </i> <code>
+ <a href="http://www.opengroup.org/onlinepubs/000095399/functions/lstat.html">
+ lstat()</a></code>.</p>
+ <blockquote>
+ <p>[<i>Note:</i> For symbolic links, <code>stat()</code> continues
+ pathname resolution using the contents of the symbolic link, <code>lstat()</code>
+ does not. <i>--
+ end note</i>]</p>
+ </blockquote>
+ <p>If the underlying file system reports an error during attribute determination:</p>
+ <ul>
+ <li>If the error indicates that <code>p</code> could not be resolved, as
+ if by POSIX errors ENOENT or ENOTDIR, call <code>ec.clear()</code> and return <code>
+ file_status(not_found_flag)</code>.</li>
+ </ul>
+ <blockquote>
+ <blockquote>
+ <p>[<i>Note:</i> The effect of this behavior is to distinguish between
+ knowing that p
+ does not exist, and not being able to determine the status of p. This
+ distinction is important to users. <i>--end note</i>]</p>
+ </blockquote>
+ </blockquote>
+ <ul>
+ <li>Otherwise, set ec to the error number reported by the underlying
+ implementation API
+ and return <code>
+ file_status(status_unknown)</code>.</li>
+ </ul>
+ <p><b><i><span style="background-color: #FFFF00">Under what conditions do
+ these functions throw? It isn't at all clear.</span></i></b></p>
+ <p>Otherwise:</p>
+ <ul>
+ <li>If the attributes indicate a regular file, as if by <i>POSIX</i> S_ISREG(),
+ return <code>
+ file_status(regular_file)</code>.</li>
+ <li>Else if the attributes indicate a directory, as if by <i>POSIX</i> S_ISDIR(),
+ return <code>
+ file_status(directory_file)</code>.</li>
+ <li>Else if the attributes indicate a symbolic link, as if by <i>POSIX</i> S_ISLNK(),
+ return <code>
+ file_status(symlink_file)</code>. <i>[Note: </i>Only possible for <code>
+ symlink_status</code>. <i>--end note]</i></li>
+ <li>Else if the attributes indicate a block special file, as if by <i>POSIX</i> S_ISBLK(),
+ return <code>
+ file_status(block_file)</code>.</li>
+ <li>Else if the attributes indicate a character special file, as if by <i>POSIX</i> S_ISCHR(),
+ return <code>
+ file_status(character_file)</code>.</li>
+ <li>Else if the attributes indicate a fifo or pipe file, as if by <i>POSIX</i> S_ISFIFO(),
+ return <code>
+ file_status(fifo_file)</code>.</li>
+ <li>Else if the attributes indicate a socket, as if by <i>POSIX</i> S_ISSOCK(),
+ return <code>
+ file_status(socket_file)</code>.</li>
+ <li>Else return <code>
+ file_status(type_unknown)</code>.</li>
+ </ul>
+ </blockquote>
+<p>[<i>Note:</i> <code>directory_file</code> implies <code>
+directory_iterator</code> on the file would succeed, and <code>
+regular_file</code> implies appropriate <code><fstream></code> operations would succeed,
+assuming no hardware, permission, access, or race
+condition errors. For <code>regular_file,</code> the converse is not true; lack of
+<code>regular_file</code> does not necessarily imply <code><fstream></code> operations would
+fail on a directory.
+<i>-- end note</i>]</p>
</blockquote>
-<pre>path complete(const path& p, const path& base=initial_path());</pre>
+<pre><span style="background-color: #FFFFFF">bool <a name="status_known">status_known</a>(file_status s);</span></pre>
<blockquote>
- <p><i>Effects:</i> Composes a complete 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>
- <td align="center"> </td>
- <td align="center"><b><code>p.has_root_directory()</code></b></td>
- <td align="center"><b><code>!p.has_root_directory()</code></b></td>
- </tr>
- <tr>
- <td align="center"><b><code>p.has_root_name()</code></b></td>
- <td align="center"><code>p</code></td>
- <td align="center">precondition failure</td>
- </tr>
- <tr>
- <td align="center"><b><code>!p.has_root_name()</code></b></td>
- <td align="center"><code>base.root_name()<br>
- / p</code></td>
- <td align="center"><code>base / p</code></td>
- </tr>
- </table>
- <p><i>Returns:</i> The composed path.</p>
- <p><i>Postcondition:</i> For the returned path, <code>rp,</code> <code>
- rp.is_complete()</code> is true.</p>
- <p><i>Throws:</i>
- <span style="background-color: #FFFFFF">If </span> <code>
- <span style="background-color: #FFFFFF">!(base.is_complete() && (p.is_complete() || !p.has_root_name()))</span></code></p>
- <p>[<i><a name="complete_note">Note</a>:</i> When portable behavior is
- required, use <i>complete()</i>. When operating system dependent behavior is
- required, use <i>system_complete()</i>.</p>
- <p>Portable behavior is useful when dealing with paths created
- internally within a program, particularly if the program should exhibit the
- same behavior on all operating systems.</p>
- <p>Operating system dependent behavior is useful when dealing with
- paths supplied by user input, reported to program users, or when such behavior
- is expected by program users. <i>--
- end note</i>]</p>
+ <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF">
+ <code>s.type() != status_unknown</code></span></p>
+</blockquote>
+<pre>file_status <a name="symlink_status">symlink_status</a>(const path& p, system::error_code& ec=throws());</pre>
+<blockquote>
+<pre><i>See status() above.</i></pre>
</blockquote>
-<pre>path system_complete(const path& p);</pre>
+<pre>path <a name="system_complete">system_complete</a>(const path& p, system::error_code& ec=throws());</pre>
<blockquote>
<p><i>Effects:</i> Composes a complete path from <code>p</code>, using the
same rules used by the operating system to resolve a path passed as the
@@ -2434,17 +2377,6 @@
<i>complete()</i> note</a> for usage suggestions. <i>-- end note</i>]</p>
</blockquote>
<h4><a name="Convenience-functions">Convenience functions</a></h4>
-<pre>bool create_directories(const Path & p);</pre>
-<blockquote>
- <p><i>Requires:</i> <code>p.empty() || <br>
- forall px: px == p || is_parent(px, p): is_directory(px) || !exists( px )</code>
- </p>
- <p><i>Returns:</i> The value of <code>!exists(p)</code> prior to the
- establishment of the postcondition.</p>
- <p><i>Postcondition:</i> <code>is_directory(p)</code></p>
- <p><i>Throws:</i> <code>basic_filesystem_error<Path></code> if<code>
- exists(p) && !is_directory(p)</code></p>
-</blockquote>
<table border="1" cellpadding="5" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td>
@@ -3187,7 +3119,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 September 2009<!--webbot bot="Timestamp" endspan i-checksum="39498" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->06 October 2009<!--webbot bot="Timestamp" endspan i-checksum="32669" --></p>
</body>
Modified: sandbox/filesystem-v3/libs/filesystem/src/operations.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/operations.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/operations.cpp 2009-10-06 08:39:09 EDT (Tue, 06 Oct 2009)
@@ -1550,10 +1550,10 @@
{
if ( (handle = ::opendir( dir )) == 0 )
return error_code( errno, system_category );
- target = string( "." ); // string was static but caused trouble
- // when iteration called from dtor, after
- // static had already been destroyed
- std::size_t path_size;
+ target = string( "." ); // string was static but caused trouble
+ // when iteration called from dtor, after
+ // static had already been destroyed
+ std::size_t path_size (0); // initialization quiets gcc warning (ticket #3509)
error_code ec = path_max( path_size );
if ( ec ) return ec;
dirent de;
Modified: sandbox/filesystem-v3/libs/filesystem/test/path_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/path_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/path_test.cpp 2009-10-06 08:39:09 EDT (Tue, 06 Oct 2009)
@@ -590,6 +590,28 @@
BOOST_TEST( p1 == p3.string().c_str() );
BOOST_TEST( p1.string() == p3 );
BOOST_TEST( p1.string().c_str() == p3 );
+
+ if ( platform == "Windows" )
+ {
+ path p10 ("c:\\file");
+ path p11 ("c:/file");
+ // check each overload
+ BOOST_TEST( p10.string() == p11.string() );
+ BOOST_TEST( p10 == p11 );
+ BOOST_TEST( p10 == p11.string() );
+ BOOST_TEST( p10 == p11.string().c_str() );
+ BOOST_TEST( p10.string() == p11 );
+ BOOST_TEST( p10.string().c_str() == p11 );
+ BOOST_TEST( p10 == "c:\\file" );
+ BOOST_TEST( p10 == "c:/file" );
+ BOOST_TEST( p11 == "c:\\file" );
+ BOOST_TEST( p11 == "c:/file" );
+ BOOST_TEST( "c:\\file" == p10 );
+ BOOST_TEST( "c:/file" == p10 );
+ BOOST_TEST( "c:\\file" == p11 );
+ BOOST_TEST( "c:/file" == p11 );
+ }
+
}
// query_and_decomposition_tests -----------------------------------------//
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