|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58980 - in sandbox/filesystem-v3: boost/filesystem libs/filesystem/doc libs/filesystem/example libs/filesystem/src libs/filesystem/test
From: bdawes_at_[hidden]
Date: 2010-01-13 10:54:38
Author: bemandawes
Date: 2010-01-13 10:54:36 EST (Wed, 13 Jan 2010)
New Revision: 58980
URL: http://svn.boost.org/trac/boost/changeset/58980
Log:
Add pathname as exposition only private member of path. Change implementation accordingly. Add template versions of native and generic observers. Rename observer functions for increased clarity.
Text files modified:
sandbox/filesystem-v3/boost/filesystem/operations.hpp | 16
sandbox/filesystem-v3/boost/filesystem/path.hpp | 152 +++---
sandbox/filesystem-v3/libs/filesystem/doc/reference.html | 895 +++++++++++++++------------------------
sandbox/filesystem-v3/libs/filesystem/doc/tutorial.html | 58 +-
sandbox/filesystem-v3/libs/filesystem/example/error_demo.cpp | 10
sandbox/filesystem-v3/libs/filesystem/example/path_info.cpp | 32
sandbox/filesystem-v3/libs/filesystem/example/simple_ls.cpp | 7
sandbox/filesystem-v3/libs/filesystem/src/operations.cpp | 4
sandbox/filesystem-v3/libs/filesystem/src/path.cpp | 197 ++++----
sandbox/filesystem-v3/libs/filesystem/src/unique_path.cpp | 2
sandbox/filesystem-v3/libs/filesystem/test/deprecated_test.cpp | 4
sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp | 16
sandbox/filesystem-v3/libs/filesystem/test/path_test.cpp | 24
sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp | 36
14 files changed, 629 insertions(+), 824 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-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -462,18 +462,18 @@
directory_entry() {}
explicit directory_entry(const boost::filesystem::path& p,
file_status st = file_status(), file_status symlink_st=file_status())
- : m_path(p), m_status(st), m_symlink_status(symlink_st)
+ : m_pathname(p), m_status(st), m_symlink_status(symlink_st)
{}
void assign(const boost::filesystem::path& p,
file_status st = file_status(), file_status symlink_st = file_status())
- { m_path = p; m_status = st; m_symlink_status = symlink_st; }
+ { m_pathname = p; m_status = st; m_symlink_status = symlink_st; }
void replace_filename(const boost::filesystem::path& p,
file_status st = file_status(), file_status symlink_st = file_status())
{
- m_path.remove_filename();
- m_path /= p;
+ m_pathname.remove_filename();
+ m_pathname /= p;
m_status = st;
m_symlink_status = symlink_st;
}
@@ -484,14 +484,14 @@
{ replace_filename(p, st, symlink_st); }
# endif
- const boost::filesystem::path& path() const {return m_path;}
+ const boost::filesystem::path& path() const {return m_pathname;}
file_status status() const {return m_get_status();}
file_status status(system::error_code& ec) const {return m_get_status(&ec);}
file_status symlink_status() const {return m_get_symlink_status();}
file_status symlink_status(system::error_code& ec) const {return m_get_symlink_status(&ec);}
private:
- boost::filesystem::path m_path;
+ boost::filesystem::path m_pathname;
mutable file_status m_status; // stat()-like
mutable file_status m_symlink_status; // lstat()-like
@@ -874,13 +874,13 @@
if (!m_imp_ptr->m_path1.empty())
{
m_imp_ptr->m_what += ": \"";
- m_imp_ptr->m_what += m_imp_ptr->m_path1.native_string();
+ m_imp_ptr->m_what += m_imp_ptr->m_path1.string();
m_imp_ptr->m_what += "\"";
}
if (!m_imp_ptr->m_path2.empty())
{
m_imp_ptr->m_what += ", \"";
- m_imp_ptr->m_what += m_imp_ptr->m_path2.native_string();
+ m_imp_ptr->m_what += m_imp_ptr->m_path2.string();
m_imp_ptr->m_what += "\"";
}
}
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-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -103,7 +103,7 @@
// the AreFileApisANSI() function, or, if a conversion argument is given,
// using a conversion object modeled on std::wstring_convert.
//
- // See m_path comments for further important rationale.
+ // See m_pathname comments for further important rationale.
// Design alternative; each function can have an additional overload that
// supplies a conversion locale. For example:
@@ -147,45 +147,45 @@
path(){}
- path(const path& p) : m_path(p.m_path) {}
+ path(const path& p) : m_pathname(p.m_pathname) {}
template <class ContiguousIterator>
path(ContiguousIterator begin, ContiguousIterator end)
{
if (begin != end)
path_traits::convert(&*begin, &*begin+std::distance(begin, end),
- m_path, codecvt());
+ m_pathname, codecvt());
}
template <class Source>
path(Source const& source)
{
- path_traits::dispatch(source, m_path, codecvt());
+ path_traits::dispatch(source, m_pathname, codecvt());
}
// ----- assignments -----
path& operator=(const path& p)
{
- m_path = p.m_path;
+ m_pathname = p.m_pathname;
return *this;
}
template <class ContiguousIterator>
path& assign(ContiguousIterator begin, ContiguousIterator end)
{
- m_path.clear();
+ m_pathname.clear();
if (begin != end)
path_traits::convert(&*begin, &*begin+std::distance(begin, end),
- m_path, codecvt());
+ m_pathname, codecvt());
return *this;
}
template <class Source>
path& operator=(Source const& source)
{
- m_path.clear();
- path_traits::dispatch(source, m_path, codecvt());
+ m_pathname.clear();
+ path_traits::dispatch(source, m_pathname, codecvt());
return *this;
}
@@ -204,14 +204,14 @@
// ----- modifiers -----
- void clear() { m_path.clear(); }
- void swap(path& rhs) { m_path.swap(rhs.m_path); }
+ void clear() { m_pathname.clear(); }
+ void swap(path& rhs) { m_pathname.swap(rhs.m_pathname); }
path& remove_filename();
path& replace_extension(const path& new_extension = path());
# ifdef BOOST_POSIX_API
- path& localize() { return *this; } // POSIX m_path already localized
+ path& localize() { return *this; } // POSIX m_pathname already localized
# else // BOOST_WINDOWS_API
@@ -238,52 +238,45 @@
// this is the format of the internally stored string.
// generic: backslashes are converted to slashes
-// template< class T >
-// T string(system::error_code & ec = boost::throws()) const // internal (i.e. original) format
-// {
-// return path_traits::convert<T>(m_path, ec);
-// }
-
// ----- native format observers -----
- //
- // 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; } // Throws: nothing
- const value_type* c_str() const { return m_path.c_str(); } // Throws: nothing
+ const string_type& native() const { return m_pathname; } // Throws: nothing
+ const value_type* c_str() const { return m_pathname.c_str(); } // Throws: nothing
-# ifdef BOOST_WINDOWS_API
+ template <class String>
+ String string() const;
- const std::string native_string() const;
- const std::wstring& native_wstring() const { return m_path; }
-
-# else // BOOST_POSIX_API
+# ifdef BOOST_WINDOWS_API
+ const std::string string() const;
+ const std::wstring& wstring() const { return m_pathname; }
- const std::string& native_string() const { return m_path; }
- const std::wstring native_wstring() const
+# else // BOOST_POSIX_API
+ const std::string& string() const { return m_pathname; }
+ const std::wstring wstring() const
{
std::wstring tmp;
- if (!m_path.empty())
- path_traits::convert(&*m_path.begin(), &*m_path.begin()+m_path.size(),
+ if (!m_pathname.empty())
+ path_traits::convert(&*m_pathname.begin(), &*m_pathname.begin()+m_pathname.size(),
tmp, codecvt());
return tmp;
}
-# endif
+# endif
// ----- generic format observers -----
-# ifdef BOOST_WINDOWS_API
+ template <class String>
+ String generic_string() const;
- const std::string string() const;
- const std::wstring wstring() const;
-
-# else // BOOST_POSIX_API
+# ifdef BOOST_WINDOWS_API
+ const std::string generic_string() const;
+ const std::wstring generic_wstring() const;
- const std::string& string() const { return m_path; }
- const std::wstring wstring() const { return native_wstring(); }
+# else // BOOST_POSIX_API
+ const std::string& generic_string() const { return m_pathname; }
+ const std::wstring generic_wstring() const { return wstring(); }
-# endif
+# endif
// ----- decomposition -----
@@ -299,13 +292,13 @@
// ----- query -----
- bool empty() const { return m_path.empty(); } // name consistent with std containers
+ bool empty() const { return m_pathname.empty(); } // name consistent with std containers
bool has_root_path() const { return has_root_directory() || has_root_name(); }
bool has_root_name() const { return !root_name().empty(); }
bool has_root_directory() const { return !root_directory().empty(); }
bool has_relative_path() const { return !relative_path().empty(); }
bool has_parent_path() const { return !parent_path().empty(); }
- bool has_filename() const { return !m_path.empty(); }
+ bool has_filename() const { return !m_pathname.empty(); }
bool has_stem() const { return !stem().empty(); }
bool has_extension() const { return !extension().empty(); }
bool is_absolute() const
@@ -349,7 +342,7 @@
path& remove_leaf() { return remove_filename(); }
path leaf() const { return filename(); }
path branch_path() const { return parent_path(); }
- bool has_leaf() const { return !m_path.empty(); }
+ bool has_leaf() const { return !m_pathname.empty(); }
bool has_branch_path() const { return !parent_path().empty(); }
bool is_complete() const { return is_absolute(); }
# endif
@@ -357,10 +350,10 @@
# if defined(BOOST_FILESYSTEM_DEPRECATED)
// deprecated functions with enough signature or semantic changes that they are
// not supplied by default
- const std::string file_string() const { return native_string(); }
- const std::string directory_string() const { return native_string(); }
- const std::string native_file_string() const { return native_string(); }
- const std::string native_directory_string() const { return native_string(); }
+ const std::string file_string() const { return string(); }
+ const std::string directory_string() const { return string(); }
+ const std::string native_file_string() const { return string(); }
+ const std::string native_directory_string() const { return string(); }
const string_type external_file_string() const { return native(); }
const string_type external_directory_string() const { return native(); }
@@ -385,21 +378,21 @@
# pragma warning(disable : 4251) // disable warning: class 'std::basic_string<_Elem,_Traits,_Ax>'
# endif // needs to have dll-interface...
/*
- m_path has the type, encoding, and format required by the native
+ m_pathname has the type, encoding, and format required by the native
operating system. Thus for POSIX and Windows there is no conversion for
- passing m_path.c_str() to the O/S API or when obtaining a path from the
+ passing m_pathname.c_str() to the O/S API or when obtaining a path from the
O/S API. POSIX encoding is unspecified other than for dot and slash
characters; POSIX just treats paths as a sequence of bytes. Windows
encoding is UCS-2 or UTF-16 depending on the version.
*/
- string_type m_path; // Windows: as input; backslashes NOT converted to slashes,
- // slashes NOT converted to backslashes
+ string_type m_pathname; // Windows: as input; backslashes NOT converted to slashes,
+ // slashes NOT converted to backslashes
# if defined(_MSC_VER)
# pragma warning(pop) // restore warning settings.
# endif
string_type::size_type m_append_separator_if_needed();
- // Returns: If separator is to be appended, m_path.size() before append. Otherwise 0.
+ // Returns: If separator is to be appended, m_pathname.size() before append. Otherwise 0.
// Note: An append is never performed if size()==0, so a returned 0 is unambiguous.
void m_erase_redundant_separator(string_type::size_type sep_pos);
@@ -413,9 +406,6 @@
friend class iterator;
friend bool operator<(const path& lhs, const path& rhs);
- static bool m_path_lex_compare(iterator first1, iterator last1,
- iterator first2, iterator last2);
-
// see path::iterator::increment/decrement comment below
static void m_path_iterator_increment(path::iterator & it);
static void m_path_iterator_decrement(path::iterator & it);
@@ -459,9 +449,9 @@
path m_element; // current element
const path * m_path_ptr; // path being iterated over
string_type::size_type m_pos; // position of name in
- // m_path_ptr->m_path. The
+ // m_path_ptr->m_pathname. The
// end() iterator is indicated by
- // m_pos == m_path_ptr->m_path.size()
+ // m_pos == m_path_ptr->m_pathname.size()
}; // path::iterator
//------------------------------------------------------------------------------------//
@@ -495,20 +485,30 @@
// //
//------------------------------------------------------------------------------------//
- // relational operators act as if comparing native format strings
-
+ // std::lexicographical_compare would infinately recurse because path iterators
+ // yield paths, so provide a path aware version
+ inline bool lexicographical_compare(path::iterator first1, path::iterator last1,
+ path::iterator first2, path::iterator last2)
+ {
+ for (; first1 != last1 && first2 != last2 ; ++first1, ++first2)
+ {
+ if (first1->native() < first2->native()) return true;
+ if (first2->native() < first1->native()) return false;
+ }
+ return first1 == last1 && first2 != last2;
+ }
+
inline bool operator<(const path& lhs, const path& rhs)
{
- // because path iterators yield paths, std::lexicographical_compare
- // infinately recurses, so use a path aware version
- return path::m_path_lex_compare(
- lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
+ return lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
inline bool operator<=(const path& lhs, const path& rhs) { return !(rhs < lhs); }
inline bool operator> (const path& lhs, const path& rhs) { return rhs < lhs; }
inline bool operator>=(const path& lhs, const path& rhs) { return !(lhs < rhs); }
+ // equality operators act as if comparing generic format strings, to achieve the
+ // effect of lexicographical_compare element by element compare.
// operator==() efficiency is a concern; a user reported the original version 2
// !(lhs < rhs) && !(rhs < lhs) implementation caused a serious performance problem
// for a map of 10,000 paths.
@@ -547,13 +547,13 @@
inline std::ostream& operator<<(std::ostream & os, const path& p)
{
- os << p.native_string();
+ os << p.string();
return os;
}
inline std::wostream& operator<<(std::wostream & os, const path& p)
{
- os << p.native_wstring();
+ os << p.wstring();
return os;
}
@@ -594,7 +594,7 @@
string_type::size_type sep_pos(m_append_separator_if_needed());
if (begin != end)
path_traits::convert(&*begin, &*begin+std::distance(begin, end),
- m_path, codecvt());
+ m_pathname, codecvt());
if (sep_pos)
m_erase_redundant_separator(sep_pos);
return *this;
@@ -606,12 +606,28 @@
if (path_traits::empty(source))
return *this;
string_type::size_type sep_pos(m_append_separator_if_needed());
- path_traits::dispatch(source, m_path, codecvt());
+ path_traits::dispatch(source, m_pathname, codecvt());
if (sep_pos)
m_erase_redundant_separator(sep_pos);
return *this;
}
+//--------------------------------------------------------------------------------------//
+// class path member template specializations //
+//--------------------------------------------------------------------------------------//
+
+ template <> inline
+ std::string path::string<std::string>() const { return string(); }
+
+ template <> inline
+ std::wstring path::string<std::wstring>() const { return wstring(); }
+
+ template <> inline
+ std::string path::generic_string<std::string>() const { return generic_string(); }
+
+ template <> inline
+ std::wstring path::generic_string<std::wstring>() const { return generic_wstring(); }
+
} // namespace filesystem
} // namespace boost
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-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -19,7 +19,8 @@
<img src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle" width="277" height="86" border="0"></a></td>
<td width="633" align="middle">
<font size="7">Filesystem Library<br>
- Version 3<br>
+ </font>
+ <font size="6">Version 3</font><font size="7"><br>
</font></td>
</tr>
</table>
@@ -126,66 +127,33 @@
</table>
<h2><a name="Introduction">Introduction</a></h2>
-<p>Some behavior is specified by reference to ISO/IEC 9945:2003, <i>
-POSIX</i>. How such behavior is actually implemented is unspecified.</p>
-<blockquote>
-<p>[<i>Note:</i> This constitutes an "as if" rule for implementation of
-operating system dependent behavior. Presumably implementations will usually call native
-operating system API's. <i>--end note</i>]</p>
-</blockquote>
-<p>Implementations are encouraged, but not required, to support such behavior
-
-as it is defined by <i>POSIX</i>. Implementations shall document any
-behavior that differs from the <i>POSIX</i> defined behavior. Implementations that do not support exact <i>POSIX</i> behavior are
-encouraged to provide behavior as close to <i>POSIX</i> behavior as is reasonable given the
-limitations of actual operating systems and file systems. If an implementation cannot provide any
-reasonable behavior, the implementation shall report an error in an
-implementation-defined manner.</p>
-<blockquote>
-<p>[<i>Note:</i> Such errors might be reported by an #error directive, a <code>
-static_assert</code>, a <code>filesystem_error</code> exception, a special
-return value, or some other manner. <i>--end note</i>]</p>
-</blockquote>
-<p>Specific operating systems such as <i>OpenMVS</i>,
-<i>UNIX</i>, and <i>Windows</i> are mentioned only for purposes of illustration or to
-give guidance to implementers. No slight to other operating systems is implied
-or intended.</p>
-<p>The <i>Effects</i> and <i>Postconditions</i> of functions described in this
-reference
-may not be achieved in
-the presence of race conditions. No diagnostic is required.</p>
-<p>If the possibility of race conditions makes it unreliable for a program to
-test for a precondition before calling a function described in this clause, <i>
-Requires</i> is not specified for the condition. Instead, the condition is
-specified as a <i>Throws</i> condition.</p>
-<blockquote>
-<p>[<i>Note:</i> As a design practice, preconditions are not specified when it
-is unreasonable for a program to detect them prior to calling the function. <i>
--- end note</i>]</p>
-</blockquote>
-<h3><a name="Definitions">Definitions</a></h3>
-<p>The following definitions apply throughout this reference documentation:</p>
+
+<p>This reference documentation describes components that C++ programs may use
+to perform operations involving file systems, including paths, regular files,
+and directories.</p>
+<h2><a name="Definitions">Definitions</a></h2>
+<p>The following definitions shall apply throughout this reference documentation:</p>
<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><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 are not permitted. Implementations may define additional
characters or specific names that are not permitted. Filenames <code>.</code>
and <code>..</code> 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
+ <p><i>[Note:</i> Most operating systems prohibit the ANSI control characters
(0x00-0x31) in filenames.</p>
- <p>Windows implementations prohibit the characters 0x00-0x31, <code>"</code>,<code>
+ <p>Windows prohibits the characters 0x00-0x31, <code>"</code>,<code>
*</code>,<code> :</code>,<code> <</code>,<code> ></code>,<code> ?</code>,<code>
\</code>,<code> /</code>, and<code> |</code> <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
-Pathname grammar.</p>
+root-directory<sub>opt</sub></i>, and an optional sequence of filenames. [<i>Note:</i>
+A pathname is the concrete representation of a path. <i>--end note</i>]</p>
<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>
@@ -197,11 +165,58 @@
specifier followed by a slash, or begin with two slashes, are absolute paths. <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>
+<p><b><a name="Relative-path">Relative path</a>:</b> A path that uniquely
+identifies a file only when considered relative to some other path. [<i>Note:</i>
Paths "." and ".." 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>
+path. Pathnames are formatted according to the generic pathname format or the
+native pathname format.</p>
+<p><b><i><a name="generic-pathname-format">Generic pathname format:</a></i></b></p>
+<blockquote>
+<p><i>pathname:<br>
+ root-name<sub>opt</sub>
+root-directory<sub>opt</sub> relative-path<sub>opt</sub></i></p>
+<p><i>root-name:<br>
+
+implementation-defined</i></p>
+<blockquote>
+ <blockquote>
+<p>[<i>Note:</i> Most POSIX and Windows based operating system define a name
+beginning with two slashes (or backslashes, for Windows) as a root-name
+identifying network locations. Windows defines a single letter followed by a
+<code>":"</code> as a root-name identifying a disc drive. <i>--end note</i>]</p>
+ </blockquote>
+</blockquote>
+<p><i>root-directory:<br>
+
+directory-separator</i></p>
+<p><i>relative-path:<br>
+
+filename<br>
+ relative-path
+directory-separator<br>
+ relative-path
+directory-separator filename</i></p>
+<p><i>filename:<br>
+ name<br>
+ </i><code>"."</code><i><br>
+ </i><code>
+".."</code></p>
+<p><i>directory-separator:<br>
+ <code>"/"<br>
+ "/"</code> directory-separator</i></p>
+<p>Multiple successive <i>directory-separator</i> characters are considered to
+be the same as one <i>directory-separator</i> character. The <i>filename</i>
+<code>"."</code> is considered to be a reference to the current directory. The
+<i>filename</i> <code>".."</code> is considered to be a reference to the current
+directory. Specific <i>filenames</i> may have special meaning for a particular
+operating system.</p>
+</blockquote>
+<p><b><i><a name="native-pathname-format">Native pathname format:</a></i></b>
+An implementation defined format. [<i>Note:</i> For POSIX-like operating
+systems, the native format is the same as the generic format. For Windows, the
+native format is the same as the generic format, except that directory-separator
+characters can be either slashes or backslashes. <i>--end note</i>]</p>
<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>
@@ -220,15 +235,52 @@
If the file pointed to does not exist, the symbolic link is said to be a
"dangling" symbolic link.<i> -- end note</i>]<i> </i></p>
</blockquote>
-<p><b><i><a name="Slash">Slash</a>:</i></b> The character <tt><code>'/'</code></tt>, also known as
-<i>solidus</i>.</p>
-<p><b><i><a name="Dot">Dot</a>:</i></b> The character <code>'.'</code>, also known as
-<i>period</i>.</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>
-<h3><a name="Header-filesystem-synopsis">Header <code><boost/filesystem></code> synopsis</a></h3>
+<p><b><i><a name="Dot">Dot</a>, Dot Dot:</i></b> Synonyms for the filenames <code>"."</code>
+and <code>".."</code>, respectively. The dot filename names the current
+directory. The dot dot filename names the parent directory.</p>
+<h2><a name="Conformance">Conformance</a></h2>
+<p>Behavior is sometimes specified by reference to ISO/IEC 9945:2003, <i>
+POSIX</i>. How such behavior is actually implemented is unspecified.</p>
+<blockquote>
+<p>[<i>Note:</i> This constitutes an "as if" rule for implementation of
+operating system dependent behavior. Presumably implementations will usually call native
+operating system API's. <i>--end note</i>]</p>
+</blockquote>
+<p>Implementations are encouraged, but not required, to support such behavior
+
+as it is defined by <i>POSIX</i>. Implementations shall document any
+behavior that differs from the <i>POSIX</i> defined behavior. Implementations that do not support exact <i>POSIX</i> behavior are
+encouraged to provide behavior as close to <i>POSIX</i> behavior as is reasonable given the
+limitations of actual operating systems and file systems. If an implementation cannot provide any
+reasonable behavior, the implementation shall report an error in an
+implementation-defined manner.</p>
+<blockquote>
+<p>[<i>Note:</i> Such errors might be reported by an #error directive, a <code>
+static_assert</code>, a <code>filesystem_error</code> exception, a special
+return value, or some other manner. <i>--end note</i>]</p>
+</blockquote>
+<p>Specific operating systems such as <i>OpenMVS</i>,
+<i>UNIX</i>, and <i>Windows</i> are mentioned only for purposes of illustration or to
+give guidance to implementers. No slight to other operating systems is implied
+or intended.</p>
+<p>The <i>Effects</i> and <i>Postconditions</i> of functions described in this
+reference
+may not be achieved in
+the presence of race conditions. No diagnostic is required.</p>
+<p>If the possibility of race conditions would make it unreliable for a program to
+test for a precondition before calling a function described in this clause, <i>
+Requires</i> is not specified for the condition. Instead, the condition is
+specified as a <i>Throws</i> condition.</p>
+<blockquote>
+<p>[<i>Note:</i> As a design practice, preconditions are not specified when it
+is unreasonable for a program to detect them prior to calling the function. <i>
+-- end note</i>]</p>
+</blockquote>
+<h2><a name="Header-filesystem-synopsis">Header <code><boost/filesystem></code> synopsis</a></h2>
<pre> namespace boost
{
namespace filesystem
@@ -236,6 +288,8 @@
class path;
void swap(path& lhs, path& rhs);
+ bool lexicographical_compare(path::iterator first1, path::iterator last1,
+ path::iterator first2, path::iterator last2);
bool operator==(const path& lhs, const path& rhs);
bool operator!=(const path& lhs, const path& rhs);
@@ -376,7 +430,7 @@
} // namespace filesystem
} // namespace boost</pre>
-<h4><a name="Error-reporting">Error reporting</a></h4>
+<h2><a name="Error-reporting">Error reporting</a></h2>
<p>Filesystem library functions often provide two overloads, one that
throws an exception to report file system errors, and another that sets an
<code>error_code</code>.</p>
@@ -425,7 +479,7 @@
throwing an exception as described in the C++ standard,
17.6.4.10 [res.on.exception.handling].</li>
</ul>
-<h3><a name="class-path">Class <code>path</code></a></h3>
+<h2><a name="class-path">Class <code>path</code></a></h2>
<p>An object of class <code>path</code> represents a path,
and contains a pathname Such an object is concerned only with the lexical and syntactic aspects
of a path. The path may not actually exist in external storage, and may contain pathnames which are not even valid for the current operating
@@ -479,19 +533,25 @@
path& localize(); // POSIX: no effect. Windows: convert slashes to backslashes
// native format observers
- const string_type& native() const; // native format, encoding
- const value_type* c_str() const; // native().c_str()
+ const string_type& native() const; // native format, encoding
+ const value_type* c_str() const; // native().c_str()
+
+ template <class String>
+ String string() const; // native format, uses codecvt() for encoding
- const string native_string() const; // native format, uses codecvt() for encoding
- const wstring native_wstring() const; // ditto
- const u16string native_u16string() const; // ditto
- const u32string native_u32string() const; // ditto
+ const string string() const; // native format, uses codecvt() for encoding
+ const wstring wstring() const; // ditto
+ const u16string u16string() const; // ditto
+ const u32string u32string() const; // ditto
// generic format observers
- const string string() const; // generic format, uses codecvt() for encoding
- const wstring wstring() const; // ditto
- const u16string u16string() const; // ditto
- const u32string u32string() const; // ditto
+ template <class String>
+ String generic_string() const;
+
+ const string generic_string() const; // generic format, uses codecvt() for encoding
+ const wstring generic_wstring() const; // ditto
+ const u16string generic_u16string() const; // ditto
+ const u32string generic_u32string() const; // ditto
// decomposition
path root_name() const;
@@ -525,7 +585,10 @@
// encoding conversion
static std::locale imbue( const std::locale& loc );
- static const codecvt_type & codecvt()
+ static const codecvt_type & codecvt();
+
+ private:
+ string_type pathname; // <b><i>exposition only</i></b>
};
} // namespace filesystem
@@ -533,7 +596,7 @@
<p><code><a name="value_type">value_type</a></code> is an implementation-defined typedef for the
character type used by the implementation to represent pathnames.</p>
<blockquote>
-<p><i>[Note:</i> For POSIX-like implementations, including<b> </b>Unix's, Linux,
+<p><i>[Note:</i> For POSIX-like implementations, including<b> </b>Unixes, Linux,
and
<a href="http://www.cygwin.com/">Cygwin</a>, <code>path::value_type</code>
is <code>char</code> .</p>
@@ -556,11 +619,11 @@
</blockquote>
<p><code><a name="ContiguousIterator">ContiguousIterator</a></code> is required be a standard library <code>RandomIterator</code>
compliant iterator
-pointing to contiguous storage. The iterator's value_type is required to be <code>char</code>, <code>
+pointing to contiguous storage. The iterator's value type is required to be <code>char</code>, <code>
wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</p>
<p><code>Source</code> is required to be one of:</p>
<ul>
- <li>A container. The value type is required to be <code>char</code>, <code>
+ <li>A container with a value type of <code>char</code>, <code>
wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</li>
<li>An iterator for a null terminated byte-string. The value type is required
to be <code>char</code>, <code>wchar_t</code>, <code>char16_t</code>, or <code>
@@ -569,202 +632,51 @@
wchar_t</code>, <code>char16_t</code>, or <code>char32_t</code>.</li>
<li>A <code>boost::filesystem::directory_entry</code>.</li>
</ul>
-<h4><a name="Pathname-formats">Pathname formats</a></h4>
-<p>Pathnames are in two possible formats: </p>
-<ul>
- <li><a name="Portable-pathname-format"><b><i>Generic</i></b></a><i><b><a name="Portable-pathname-format"> pathname format</a>:</b></i> As described in <a href="#Pathname-grammar">
- Pathname grammar</a> and by the <i>POSIX</i> <i>Filename,
-<a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_266">
-Pathname</a> </i>and<i>
-<a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap04.html#tag_04_11">
-Pathname Resolution</a></i> definitions.<blockquote>
-<p>[<i>Note:</i> <span style="background-color: #FFFFFF">The <i>POSIX</i> format
-is the basis for the generic format because it is already part of an ISO standard, is
-the basis for the ubiquitous <i>URL</i> format, and is the native pathname format
-(or a
-subset thereof) for the <i>UNIX</i>-like and <i>Windows</i>-like
-pathnames familiar to most programmers. </span></p>
-<p>Use of the generic format does not guarantee
-portability; filenames must also be portable.<span style="background-color: #FFFFFF">
-See Filename conversions. Each operating system
-
-follows its own rules. Use of the generic format
-does not change those rules. </span> <i>-- end note</i>]</p>
- </blockquote>
-
- </li>
- <li>
-
- <b><i><a name="Native-pathname-format">Native pathname format</a>:</i></b> As defined by the operating system.<blockquote>
- <p>[<i>Note:</i> <span style="background-color: #FFFFFF">Working with
- user-provided native format paths is a common need. Hard-coded native
- format paths, however, may not be portable. --</span><i><span style="background-color: #FFFFFF"> end note</span></i><span style="background-color: #FFFFFF">]</span></p>
- </blockquote>
- </li>
-</ul>
-<div align="left">
- <table border="1" cellpadding="10" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
- <tr>
- <td bgcolor="#D7EEFF">
- <p align="left">[<i>Note:</i><b> POSIX-like<i> </i>implementations, including Cygwin:</b>
- The native format is the same as the generic format. The pathname encoding
- follows the conventions of the specific operating system</p>
- <p align="left"><b>Windows-like implementations, including MinGW:</b> The native format is
- the Windows pathname format, and the encoding is UTF-16 (UCS-2 for older
- versions). The preferred native directory separator character is the backslash, but slash is
- also acceptable. Since the generic format is a subset of the native format,
- no reformatting is required and directory separators are preserved. For
- example, on Windows:</p>
- <blockquote>
- <p align="left"><code>path p = "foo\\bar/baz";<br>
- assert( p.native() == L"foo\\bar/baz" );<br>
- p = "baz/bar/foo";<br>
- assert( p.native() == L"baz/bar/foo" );</code></p>
- </blockquote>
- <p align="left"> <i>--end note</i>]</p>
- </td>
- </tr>
- </table>
-</div>
-<p><span style="background-color: #FFFF00">All <code>path</code> string or sequence arguments that describe a
-path shall accept the generic pathname format, and shall accept the native
-format if explicitly identified by a native format escape sequence prefix of
-<code>slash slash colon</code>.</span></p>
-<blockquote>
- <p><span style="background-color: #FFFF00">[<i>Note:</i> <code>slash
- slash colon</code> was chosen as the escape sequence because a leading <code>
- slash slash</code> is already implementation-defined by POSIX, <code>
- colon</code> is prohibited in a Windows filename, and on any system a single
- <code>slash</code> can be used when a filename beginning with a <code>colon</code>
- is desired. These factors eliminate the chance of collision with a real
- filename. --</span><i><span style="background-color: #FFFF00"> end note</span></i><span style="background-color: #FFFF00">]</span></p>
- </blockquote>
-<p><span style="background-color: #FFFF00">Implementations are encouraged to
-implicitly recognize the native pathname format if it can be lexically
-identified. An implementation shall document whether or
-not the native pathname format is
-implicitly recognized.</span></p>
-<blockquote>
-<p><span style="background-color: #FFFF00">[</span><i><span style="background-color: #FFFF00">Example:</span></i></p>
-<p><i><span style="background-color: #FFFF00">-- OpenVMS:</span></i><span style="background-color: #FFFF00">
-</span> <code><span style="background-color: #FFFF00">"SYS1::DISK1:[JANE.TYLER.HARRY]</span></code><span style="background-color: #FFFF00">" is treated
-as a native pathname with a system name, drive name, and three directory
-filenames, rather than a generic pathname with one filename.</span></p>
-<p><i><span style="background-color: #FFFF00">-- Windows: </span> </i><code>
-<span style="background-color: #FFFF00">"c:\\jane\\tyler\\harry"</span></code><span style="background-color: #FFFF00"> is treated as a
-native pathname with a drive letter, root-directory, and three filenames, rather
-than a generic pathname with one filename.</span></p>
-<p><i><span style="background-color: #FFFF00">-- Counter-example 1:</span></i><span style="background-color: #FFFF00"> An operating system that allows slashes in
-filenames and uses dot as a directory separator. Distinguishing between generic
-and native format argument strings or sequences is not possible as there is no
-other distinguishing syntax. The implementation does not accept native format
-pathnames unless the </span> <code><span style="background-color: #FFFF00">native</span></code><span style="background-color: #FFFF00"> argument is present.</span></p>
-<p><i><span style="background-color: #FFFF00">-- Counter-example 2:</span></i><span style="background-color: #FFFF00"> An operating system that allows slashes in
-filenames and uses some unusual character as a directory separator. The
-implementation does accept native format pathnames without the additional </span> <code>
-<span style="background-color: #FFFF00">native</span></code><span style="background-color: #FFFF00"> argument, which only has to be used for native format arguments
-containing slashes in filenames.</span></p>
-<p><i><span style="background-color: #FFFF00">-- end example</span></i><span style="background-color: #FFFF00">]</span></p>
-<p><span style="background-color: #FFFF00">[</span><i><span style="background-color: #FFFF00">Note:</span></i><span style="background-color: #FFFF00"> This
-</span> <i><a name="duck-rule"><span style="background-color: #FFFF00">duck-rule</span></a></i><span style="background-color: #FFFF00"> ("if it looks
-like a duck, walks like a duck, and quacks like a duck, it must be a duck")
-eliminates format confusion as a source of programmer error and support
-requests. </span> <i><span style="background-color: #FFFF00">-- end note</span></i><span style="background-color: #FFFF00">]</span></p>
-</blockquote>
-<p><span style="background-color: #FFFF00">If both the generic and native formats are accepted, implementations shall
-document what characters or character sequences are used to distinguish between
-two formats.</span></p>
-<blockquote>
-<p><span style="background-color: #FFFF00">[</span><i><span style="background-color: #FFFF00">Note:</span></i><span style="background-color: #FFFF00">
-</span> <i><span style="background-color: #FFFF00">Windows</span></i><span style="background-color: #FFFF00"> implementations are encouraged to define colons
-and backslashes as the characters which distinguish native from generic
-formats. </span> <i><span style="background-color: #FFFF00">--end note</span></i><span style="background-color: #FFFF00">]</span></p>
-</blockquote>
-<h4><a name="Pathname-grammar">Pathname grammar</a></h4>
-<p>The grammar for the generic pathname format is as follows:</p>
-<blockquote>
-<p><i>pathname:<br>
- root-name<sub>opt</sub>
-root-directory<sub>opt</sub> relative-path<sub>opt</sub></i></p>
-<p><i>root-name:<br>
-
-implementation-defined</i></p>
-<p><i>root-directory:<br>
-
-directory-separator<br>
-
-root-directory directory-separator<br>
-
-implementation-defined</i></p>
-<p><i>relative-path:<br>
-
-filename<br>
- relative-path
-directory-separator<br>
- relative-path
-directory-separator filename</i></p>
-<p><i>filename:<br>
- name<br>
- dot<br>
- dot dot</i></p>
-<p><i>directory-separator:<br>
- <code>"/"</code></i></p>
-<p><i>dot:<br>
- </i><code>"."</code></p>
-</blockquote>
-<p>The grammar is aligned with the <i>POSIX </i> <i>Filename,
-<a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_266">
-Pathname</a> </i>and<i>
-<a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap04.html#tag_04_11">
-Pathname Resolution</a></i> definitions. Any conflict between the grammar and <i>
-POSIX</i> is unintentional. This technical report defers to <i>POSIX</i>.</p>
-<blockquote>
-<p><span style="background-color: #E0E0E0"><i>The form of the above wording was taken
-from POSIX, which uses it in several places to defer to the C standard.</i></span></p>
-<p><span style="background-color: #FFFF00">[</span><i><span style="background-color: #FFFF00">Note: Windows</span></i><span style="background-color: #FFFF00"> implementations are encouraged to define
-</span> <i><span style="background-color: #FFFF00">slash slash
-name</span></i><span style="background-color: #FFFF00"> as a permissible </span> <i>
-<span style="background-color: #FFFF00">root-name</span></i><span style="background-color: #FFFF00">.
-</span> <i><span style="background-color: #FFFF00">POSIX</span></i><span style="background-color: #FFFF00"> permits, but does not
-require, implementations to do the same. </span> <i>
-<span style="background-color: #FFFF00">Windows</span></i><span style="background-color: #FFFF00"> implementations are
-encouraged to define an additional </span> <i>
-<span style="background-color: #FFFF00">root-directory</span></i><span style="background-color: #FFFF00"> element
-</span> <i>
-<span style="background-color: #FFFF00">root_directory name.</span></i><span style="background-color: #FFFF00"> It is applicable only to the
-</span> <i><span style="background-color: #FFFF00">slash slash name</span></i><span style="background-color: #FFFF00">
-form of </span> <i><span style="background-color: #FFFF00">root-name.</span></i></p>
-<p> <i><span style="background-color: #FFFF00">Windows</span></i><span style="background-color: #FFFF00"> implementations are encouraged to recognize a
-</span> <i><span style="background-color: #FFFF00">name</span></i><span style="background-color: #FFFF00">
-followed by a colon as a native format </span> <i>
-<span style="background-color: #FFFF00">root-name</span></i><span style="background-color: #FFFF00">,
-and a backslash as a format element equivalent to </span> <i>
-<span style="background-color: #FFFF00">slash</span></i><span style="background-color: #FFFF00">.
-</span> <i><span style="background-color: #FFFF00">-- end note</span></i><span style="background-color: #FFFF00">]</span></p>
-</blockquote>
-<h4><a name="Input-conversion">Input conversion</a></h4>
-<p><span style="background-color: #FFFF00">To be supplied. Explain when, how
-codecvt applied.</span></p>
-<p><span style="background-color: #FFFF00">When converting filenames to the native operating system format,
+<p>Iteration over <code><a name="ContiguousIterator">ContiguousIterator</a></code>
+and <code>Source</code> arguments shall result in generic pathname format or
+native pathname format strings.</p>
+<p>The specifications for certain <code>path</code> functions require that
+arguments in the generic pathname format be converted to native pathname format
+as they are stored in <code>pathname</code>. If the native format requires
+regular file paths and directory paths to be formatted differently, the
+implementation shall determine which format to use according to whether or not
+the last element of the generic format string is a separator. [<i>Example:</i>
+On OpenVMS, a path
+constructed from <code>"/cats/jane"</code> would considered a regular file
+path, and have a native format of <code>"[CATS]JANE"</code>, while a
+path constructed from <code>"/cats/jane/"</code> would be considered a
+directory path, and have a native format of <code>"[CATS.JANE]"</code>.
+<i>--end example</i>] [<i>Note</i>: POSIX and Windows use the same native format
+for regular file and directory pathnames, so this paragraph does not apply to
+them. <i>--end note</i>]</p>
+
+<table align="center" border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#D7EEFF" width="90%">
+ <tr>
+ <td style="font-size: 10pt">
+ Class <code>path</code> does not currently map invalid characters in
+ filenames to valid characters. In the future we might add something like
+ this:<blockquote>
+<p>When converting filenames to the native operating system format,
implementations are encouraged, but not required, to convert otherwise invalid
characters or character sequences to valid characters or character sequences.
-Such conversions are implementation-defined.</span></p>
+Such conversions are implementation-defined.</p>
<blockquote>
-<p><span style="background-color: #FFFF00">[</span><i><span style="background-color: #FFFF00">Note:</span></i><span style="background-color: #FFFF00"> Filename conversion allows much wider portability of both
-programs and filenames that would otherwise be possible.</span></p>
-<p><span style="background-color: #FFFF00">Implementations are encouraged to base conversion on existing standards or
-practice. Examples include the Uniform Resource Locator escape syntax of a percent sign (</span><code><span style="background-color: #FFFF00">'%'</span></code><span style="background-color: #FFFF00">)
-followed by two hex digits representing the character value. On </span>
-<i><span style="background-color: #FFFF00">OpenVMS</span></i><span style="background-color: #FFFF00">, which does not allow percent signs in filenames, a dollar sign (</span><code><span style="background-color: #FFFF00">'$'</span></code><span style="background-color: #FFFF00">)
+<p>[<i>Note:</i> Filename conversion allows much wider portability of both
+programs and filenames that would otherwise be possible.</p>
+<p>Implementations are encouraged to base conversion on existing standards or
+practice. Examples include the Uniform Resource Locator escape syntax of a percent sign (<code>'%'</code>)
+followed by two hex digits representing the character value. On
+<i>OpenVMS</i>, which does not allow percent signs in filenames, a dollar sign (<code>'$'</code>)
followed by two hex digits is the existing practice, as is converting lowercase
-letters to uppercase.</span><i><span style="background-color: #FFFF00"> -- end note.</span></i><span style="background-color: #FFFF00">]</span></p>
-<p><span style="background-color: #E0E0E0"><i>The Boost implementation for
-Windows currently does not map invalid characters. Pending feedback from the LWG,
-Boost may settle on % hex hex as the preferred escape sequence. If so, should
-there be normative encouragement?</i></span></p>
+letters to uppercase.<i> -- end note.</i>]</p>
</blockquote>
-<h4> <code><font size="4">class </font></code> <a name="path-constructors"> <code>
-<font size="4">path</font></code> constructors</a></h4>
+ </blockquote>
+ </td>
+ </tr>
+</table>
+
+<h3> <a name="path-constructors"> <code>
+<font size="4">path</font></code> constructors</a></h3>
<pre>path();</pre>
<blockquote>
<p><i>Postconditions:</i> <code>empty()</code>.</p>
@@ -775,31 +687,40 @@
path(Source const& source);</pre>
<blockquote>
<p><i>Effects:</i> Stores the contents [<code>begin</code>,<code>end</code>)
- or <code>source</code>, in the native format, as the contained pathname.</p>
+ or <code>source</code> in <code>pathname</code>. If the contents are in the
+ generic format, they are converted to the native format. [<i>Note:</i> For
+ POSIX and Windows based implementations, the generic format is already
+ acceptable as a native format, so no generic to native conversion is
+ performed. <i>--end note</i>]</p>
<p>
<i>Remarks:</i> If the value type of [<code>begin</code>,<code>end</code>)
or <code>source</code> is not <code>value_type</code>, the contents are
converted by <code>codecvt()</code>.</p>
</blockquote>
-<h4> <code><font size="4">class </font></code> <a name="path-assignments"> <code>
-<font size="4">path</font></code> assignments</a></h4>
+<h3> <a name="path-assignments"> <code>
+<font size="4">path</font></code> assignments</a></h3>
<pre>template <class ContiguousIterator>
path& assign(ContiguousIterator begin, ContiguousIterator end);</pre>
<pre>template <class Source>
path& operator=(Source const& source);</pre>
<blockquote>
<p><i>Effects:</i> Stores the contents [<code>begin</code>,<code>end</code>)
- or <code>source</code>, in the native format, as the contained pathname.</p>
+ or <code>source</code> in <code>pathname</code>. If the contents are in the
+ generic format, they are converted to the native format. [<i>Note:</i> For
+ POSIX and Windows based implementations, the generic format is already
+ acceptable as a native format, so no generic to native conversion is
+ performed. <i>--end note</i>]</p>
+ <p>
+ <i>Returns: </i><code>*this</code></p>
<p>
<i>Remarks:</i> If the value type of [<code>begin</code>,<code>end</code>)
or <code>source</code> is not <code>value_type</code>, the contents are
converted by <code>codecvt()</code>.</p>
- <p><i>Returns: </i><code>*this</code></p>
</blockquote>
-<h4> <code><font size="4">class <a name="path-appends">path</a></font></code><a name="path-appends">
-appends</a></h4>
+<h3> <code><font size="4"> <a name="path-appends">path</a></font></code><a name="path-appends">
+appends</a></h3>
<p>The append operations use <code>operator/=</code> to denote their semantic
- effect of appending the platform's preferred directory separator when needed. The
+ effect of appending the platform's preferred directory separator when needed. The
preferred
directory separator is implementation-defined.</p>
<blockquote>
@@ -822,7 +743,7 @@
<li><code>p.empty()</code>, or</li>
<li><code>*p.native().cbegin()</code> is a directory separator.</li>
</ul>
- <p>Appends <code>p.native()</code> to the contained pathname.</p>
+ <p>Appends <code>p.native()</code> to <code>pathname</code>.</p>
</blockquote>
<p><i>Returns: </i><code>*this</code></p>
</blockquote>
@@ -842,15 +763,20 @@
<li><code>*p.native().cbegin()</code> is a separator.</li>
</ul>
<p>Appends the contents [<code>begin</code>,<code>end</code>)
- or <code>source</code>, in the native format, to the contained pathname.</p>
+ or <code>source</code> to <code>pathname</code>. If the contents are in the
+ generic format, they are converted to the native format. [<i>Note:</i> For
+ POSIX and Windows based implementations, the generic format is already
+ acceptable as a native format, so no generic to native conversion is
+ performed. <i>--end note</i>]</p>
</blockquote>
<p><i>Remarks:</i> If the value type of [<code>begin</code>,<code>end</code>)
or <code>source</code> is not <code>value_type</code>, the contents are
converted by <code>codecvt()</code>.</p>
<p><i>Returns: </i><code>*this</code></p>
</blockquote>
-<h4> <code><font size="4">class </font></code> <a name="path-modifiers"> <code>
-<font size="4">path</font></code> modifiers</a></h4>
+
+<h3> <a name="path-modifiers"> <code>
+<font size="4">path</font></code> modifiers</a></h3>
<pre>void clear();</pre>
<blockquote>
<p><i>Postcondition:</i> <code>this->empty()</code> is true.</p>
@@ -888,110 +814,89 @@
backslashes. On POSIX, there is no effect. <i>-- end note</i>]</p>
<p><i>Returns:</i> <code>*this</code></p>
</blockquote>
-<h4> <a name="path-observers"> <code>
-<font size="4"><span style="background-color: #FFFF00">path native format</span></font></code><span style="background-color: #FFFF00"> observers</span></a></h4>
-<p><span style="background-color: #FFFF00"><i>Move elsewhere.</i> </span></p>
-<p><span style="background-color: #FFFF00">Some operating systems, including
-</span> <i><span style="background-color: #FFFF00">POSIX</span></i><span style="background-color: #FFFF00"> and
-</span> <i>
-<span style="background-color: #FFFF00">Windows</span></i><span style="background-color: #FFFF00">, use the same format for paths to directories and paths to regular
-files.</span></p>
-<p><span style="background-color: #FFFF00">Other operating systems, such as
-</span><span style="background-color: #FFFF00">OpenVMS</span><span style="background-color: #FFFF00">, used different formats for paths to
-directories and paths to regular files. On such systems, implementations shall
-determine the format according to whether or not the last element is a
-separator.</span></p>
-<table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
- <tr>
- <td colspan="2">
- <p align="center"><b><span style="background-color: #FFFF00">OpenVMS</span></b></td>
- </tr>
- <tr>
- <td><code><span style="background-color: #FFFF00">path p</span></code></td>
- <td><code><span style="background-color: #FFFF00">p.native()</span></code></td>
- </tr>
- <tr>
- <td><code><span style="background-color: #FFFF00">p = "/cats/jane"</span></code></td>
- <td> <code><span style="background-color: #FFFF00">"[CATS]JANE"</span></code></td>
- </tr>
- <tr>
- <td><code><span style="background-color: #FFFF00">p = "/cats/jane/"</span></code></td>
- <td> <code><span style="background-color: #FFFF00">"[CATS.JANE]"</span></code></td>
- </tr>
-</table>
+
+<h3><code><font size="4">path</font></code><font size="4"> <a name="path-native-format-observers">
+native format</a></font><a name="path-native-format-observers"> observers</a></h3>
+<p>The string returned by all native format observers is in the native pathname format.</p>
<pre>const string_type& native() const;</pre>
<blockquote>
-<p><i>Returns:</i> The contained pathname. [<i>Note:</i> The contained pathname
-is in the native pathname format. <i>--
-end note</i>]</p>
+<p><i>Returns:</i> <code>pathname</code>.</p>
<p><i>Throws:</i> nothing.</p>
</blockquote>
<pre>const value_type* c_str() const;</pre>
<blockquote>
-<p><i>Returns:</i> <code>native().c_str()</code>.</p>
+<p><i>Returns:</i> <code>pathname.c_str()</code>.</p>
<p><i>Throws:</i> nothing.</p>
</blockquote>
-<pre><i><b>const-string</b></i> native_string() const;</pre>
-<blockquote>
-<p><b><i><code>const-string</code></i></b> is permitted to be <code>const
-std::string</code> or <code>const std::string&</code>.</p>
-<p><i>Returns:</i> The contained pathname. [<i>Note:</i> The contained pathname
-is in the native pathname format. <i>--
-end note</i>]</p>
-<p><i>Remarks:</i> If
-<code>value_type</code> is not <code>char</code>, the encoding is converted by
-<code>codecvt()</code>.</p>
-<p><i>[Note:</i> For POSIX-like implementations, no conversion is required; the
-implementation will simply return <code>native()</code>. <i>-- end note]</i></p>
-</blockquote>
-<pre><i><b>const-wstring</b></i> native_wstring() const; </pre>
+<pre>template <class String>
+String string() const;</pre>
<blockquote>
-<p><b><i><code>const-wstring</code></i></b> is permitted to be <code>const
-std::wstring</code> or <code>const std::wstring&</code>.</p>
-<p><i>Returns:</i> The contained pathname. [<i>Note:</i> The contained pathname
-is in the native pathname format. <i>--
-end note</i>]</p>
-<p><i>Remarks:</i> If
-<code>value_type</code> is not <code>wchar_t</code>, the encoding is converted by
+ <p><i>Returns:</i> <code>pathname</code>.</p>
+<p><i>Remarks:</i> If <code>pathname</code> is of a different type than <code>
+String</code>, conversion is performed using
<code>codecvt()</code>.</p>
-<p><i>[Note:</i> For Windows implementations, no conversion is required; the
-implementation will simply return <code>native()</code>. <i>-- end note]</i></p>
</blockquote>
-<pre><b><i>const-string</i></b> string() const;</pre>
-<blockquote>
-<p><b><i><code>const-string</code></i></b> is permitted to be <code>const
-std::string</code> or <code>const std::string&</code>.</p>
-<p><i>Returns:</i> The contained pathname, in the
-generic pathname format.</p>
-<p><i>Remarks:</i> If
-<code>value_type</code> is not <code>char</code>, the encoding is converted by
+<pre>const string string() const;
+const wstring wstring() const;
+const u16string u16string() const;
+const u32wstring u32wstring() const; </pre>
+<blockquote>
+<p><i>Returns:</i> <code>pathname</code>.</p>
+<p><i>Remarks:</i> If <code>pathname</code> is not of the same type as the
+function's return type, conversion is performed using
+<code>codecvt()</code>. If <code>pathname</code> is of the same type as the
+function's return type, the function is permitted to return by <code>const&</code>
+rather than <code>const</code> value. [<i>Note:</i> For POSIX, this occurs for
+<code>string()</code>, for Windows, <code>wstring()</code>. <i>--end note</i>]</p>
+</blockquote>
+
+<h3><code><font size="4">path</font></code><font size="4">
+<a name="path-generic-format-observers">generic format</a></font><a name="path-native-format-observers">
+observers</a></h3>
+<p>The string returned by all generic format observers is in the
+generic pathname format.</p>
+<p>[<i>Note:</i> For POSIX, no conversion occurs, since the native format and
+generic format are the same. For Windows, backslashes are converted to slashes
+<i>--end note</i>]</p>
+<pre>template <class String>
+String generic_string() const;</pre>
+<blockquote>
+ <p><i>Returns:</i> <code>pathname</code>.</p>
+<p><i>Remarks:</i> If <code>pathname</code> is of a different type than <code>
+String</code>, conversion is performed using
<code>codecvt()</code>.</p>
</blockquote>
-<pre><b><i>const-wstring</i></b> wstring() const;</pre>
-<blockquote>
-<p><b><i><code>const-wstring</code></i></b> is permitted to be <code>const
-std::wstring</code> or <code>const std::wstring&</code>.</p>
-<p><i>Returns:</i> The contained pathname, in the
-generic pathname format.</p>
-<p><i>Remarks:</i> If
-<code>value_type</code> is not <code>wchar_t</code>, the encoding is converted by
-<code>codecvt()</code>.</p>
+<pre>const string generic_string() const;
+const wstring generic_wstring() const;
+const u16string generic_u16string() const;
+const u32wstring generic_u32wstring() const; </pre>
+<blockquote>
+<p><i>Returns:</i> <code>pathname</code>.</p>
+<p><i>Remarks:</i> If <code>pathname</code> is not of the same type as the
+function's return type, conversion is performed using
+<code>codecvt()</code>. If <code>pathname</code> is of the same type as the
+function's return type, and the generic format is the same as the native format,
+the function is permitted to return by <code>const&</code> rather than <code>
+const</code> value. [<i>Note:</i> For POSIX, this occurs for <code>string()</code>.
+It never occurs for Windows, because backslashes must be converted to slashes.
+<i>--end note</i>]</p>
</blockquote>
-<h4> <a name="path-decomposition"> <code><font size="4">class path</font></code>
-decomposition</a></h4>
+
+<h3> <a name="path-decomposition"> <code><font size="4">path</font></code>
+decomposition</a></h3>
<p><span style="background-color: #E0E0E0"><i>See the
<a href="#Path-decomposition-table">Path decomposition table</a> for examples
for values returned by decomposition functions.</i></span></p>
<pre>path root_name() const;</pre>
<blockquote>
-<p><i>Returns:</i> <i>root-name,</i> if the stored path includes <i>
+<p><i>Returns:</i> <i>root-name,</i> if <code>pathname</code> includes <i>
root-name</i>, otherwise <code>path()</code>. </p>
</blockquote>
<pre>path root_directory() const;</pre>
<blockquote>
-<p><i>Returns:</i> <i>root-directory</i>, if the stored path includes <i>
+<p><i>Returns:</i> <i>root-directory</i>, if <code>pathname</code> includes <i>
root-directory</i>, otherwise <code>path()</code>.</p>
-<p>If <i>root-directory</i> is composed <i>slash name</i>, <i>slash</i> is
+<p>If <i>root-directory</i> is composed of <i>slash name</i>, <i>slash</i> is
excluded from the returned string.</p>
</blockquote>
<pre>path root_path() const;</pre>
@@ -1000,7 +905,8 @@
</blockquote>
<pre>path relative_path() const;</pre>
<blockquote>
-<p><i>Returns:</i> A <code>path</code> composed from the the stored path, if any, beginning
+<p><i>Returns:</i> A <code>path</code> composed from <code>pathname</code>, if <code>
+!empty()</code>, beginning
with the first <i>filename</i> after <i>root-path</i>. Otherwise, <code>path()</code>.</p>
</blockquote>
<pre>path filename() const;</pre>
@@ -1037,7 +943,7 @@
behavior for file systems which append additional elements to extensions, such
as alternate data streams or partitioned dataset names.</p>
</blockquote>
-<h4> <a name="path-query"> <code><font size="4">class path</font></code> query</a></h4>
+<h3> <a name="path-query"> <code><font size="4">path</font></code> query</a></h3>
<pre>bool empty() const;</pre>
<blockquote>
<p><i>Returns:</i> <code>native().empty()</code>.</p>
@@ -1086,14 +992,14 @@
<blockquote>
<p><span style="background-color: #FFFFFF"><i>Returns:</i> <code>!is_absolute()</code>.</span></p>
</blockquote>
-<h4> <code><font size="4">class </font></code> <a name="path-iterators"> <code>
-<font size="4">path</font></code> iterators</a></h4>
+<h3> <a name="path-iterators"> <code>
+<font size="4">path</font></code> iterators</a></h3>
<p> A <code>path::iterator</code> is a constant iterator satisfying all
the requirements of a bidirectional iterator (C++ Std, 24.1.4 Bidirectional
-iterators [lib.bidirectional.iterators]). Its <code>value_type</code> is
-<code>string_type</code>.</p>
+iterators [lib.bidirectional.iterators]). Its <code>value_type</code> is <code>
+path</code>.</p>
<p>Calling any non-const member function of a <code>path</code> object
- invalidates all iterators referring to elements of the object.</p>
+ invalidates all iterators referring to elements of that object.</p>
<p> The forward traversal order is as follows:</p>
<ul>
<li>The <i>root-name</i> element, if present.</li>
@@ -1112,11 +1018,11 @@
<blockquote>
<p><i>Returns:</i> The end iterator.</p>
</blockquote>
-<h4> <code><font size="4">class <a name="path-deprecated-functions">path</a></font></code><a name="path-deprecated-functions">
-deprecated functions</a></h4>
-<p> <span style="background-color: #FFFF00">index.htm</span><span style="background-color: #FFFF00">
+<h3> <code><font size="4"> <a name="path-deprecated-functions">path</a></font></code><a name="path-deprecated-functions">
+deprecated functions</a></h3>
+<p> <i> <span style="background-color: #FFFF00">index.htm
also has a section (see macros) partially duplicating this material. Change to
-reference this.</span></p>
+reference this.</span></i></p>
<p> Several member functions from previous versions of <code>class path</code>
have been deprecated, either because they have been renamed or because the
functionality is no longer desirable or has become obsolete.</p>
@@ -1141,204 +1047,97 @@
</blockquote>
<p>Functions no longer available:</p>
<p><span style="background-color: #FFFF00">TBS</span></p>
-<h4> <a name="path-non-member-functions">
-<span style="background-color: #FFFFFF">path non-member functions</span></a></h4>
-<pre><span style="background-color: #FFFFFF">template<class String, class Traits>
-void swap( path<String, Traits> & lhs, path<String, Traits> & rhs )</span></pre>
+<h3> <a name="path-non-member-functions"> <code><font size="4">path</font></code>
+<span style="background-color: #FFFFFF">non-member functions</span></a></h3>
+<pre><span style="background-color: #FFFFFF">void swap( path& lhs, path& rhs )</span></pre>
<blockquote>
<p><i><span style="background-color: #FFFFFF">Effects: </span></i><code>
- <span style="background-color: #FFFFFF">lhs.swap(
- rhs )</span></code></p>
+ <span style="background-color: #FFFFFF">lhs.swap(rhs)</span></code>.</p>
</blockquote>
- <h4><span style="background-color: #FFFFFF">path non-member operators</span></h4>
- <p><span style="background-color: #FF0000">There are seven path non-member operators (/,
- </span> <code><span style="background-color: #FF0000">==</span></code><span style="background-color: #FF0000">,
- </span> <code>
- <span style="background-color: #FF0000">!=</span></code><span style="background-color: #FF0000">,
- </span> <code><span style="background-color: #FF0000"><</span></code><span style="background-color: #FF0000">,
- </span> <code><span style="background-color: #FF0000">></span></code><span style="background-color: #FF0000">,
- </span> <code><span style="background-color: #FF0000"><=</span></code><span style="background-color: #FF0000">,
- </span> <code><span style="background-color: #FF0000">>=</span></code><span style="background-color: #FF0000">),
- each with five overloads. For brevity, the specifications are given in tabular
- form. Each of the resulting thirty-five signatures is a template, with
- template parameter list template</span><code><span style="background-color: #FF0000"><class
- String, class Traits></span></code><span style="background-color: #FF0000">.
- The format of such arguments is described in </span> <a href="#Pathname-formats">
- <span style="background-color: #FF0000">Pathname formats</span></a><span style="background-color: #FF0000">.</span></p>
- <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="150">
- <tr>
- <td width="100%" height="16">
- <p align="center"><i><b><span style="background-color: #FF0000">Argument type overloads</span></b></i></td>
- </tr>
- <tr>
- <td width="100%" height="16"><code>
- <span style="background-color: #FF0000">path<String, Traits>& a, path<String, Traits>&
- b</span></code></td>
- </tr>
- <tr>
- <td width="100%" height="16"><code>
- <span style="background-color: #FF0000">const
- typename path<String, Traits>::string_type& a,
- path<String, Traits>& b</span></code></td>
- </tr>
- <tr>
- <td width="100%" height="16"><code>
- <span style="background-color: #FF0000">const
- typename path<String, Traits>::string_type::value_type* a,
- path<String, Traits>& b</span></code></td>
- </tr>
- <tr>
- <td width="100%" height="5"><code>
- <span style="background-color: #FF0000">const
- path<String, Traits>& a, typename path<String, Traits>::string_type&
- b</span></code></td>
- </tr>
- <tr>
- <td width="100%" height="16"><code>
- <span style="background-color: #FF0000">const
- path<String, Traits>& a, typename
- path<String, Traits>::string_type::value_type* b</span></code></td>
- </tr>
- </table>
- <p><span style="background-color: #FF0000">In the </span><b><i>
- <span style="background-color: #FF0000">path non-member operators </span>
- </i></b><span style="background-color: #FF0000">table, </span><code>
- <span style="background-color: #FF0000">a</span></code><span style="background-color: #FF0000">
- and </span><code><span style="background-color: #FF0000">b</span></code><span style="background-color: #FF0000">
- are of the types given in the </span><i><b>
- <span style="background-color: #FF0000">Argument type overloads</span></b></i><span style="background-color: #FF0000">
- table. If </span><code><span style="background-color: #FF0000">a</span></code><span style="background-color: #FF0000">
- or </span><code><span style="background-color: #FF0000">b</span></code><span style="background-color: #FF0000">
- is of type </span><code><span style="background-color: #FF0000">const
- path<String, Traits>&</span></code><span style="background-color: #FF0000">,
- then </span><i><b><span style="background-color: #FF0000">a</span></b></i><code><i><b><span style="background-color: #FF0000">'</span></b></i></code><span style="background-color: #FF0000">
- or </span><i><b><span style="background-color: #FF0000">b'</span></b></i><span style="background-color: #FF0000">
- respectively is </span><code><span style="background-color: #FF0000">a</span></code><span style="background-color: #FF0000">
- or </span><code><span style="background-color: #FF0000">b</span></code><span style="background-color: #FF0000">
- respectively. Otherwise </span><i><b><span style="background-color: #FF0000">a</span></b></i><code><i><b><span style="background-color: #FF0000">'</span></b></i></code><span style="background-color: #FF0000">
- or </span><i><b><span style="background-color: #FF0000">b'</span></b></i><span style="background-color: #FF0000">
- respectively represent named or unnamed temporary </span><code>
- <span style="background-color: #FF0000">path<String, Traits></span></code><span style="background-color: #FF0000">
- objects constructed from </span><code><span style="background-color: #FF0000">
- a</span></code><span style="background-color: #FF0000"> or </span><code>
- <span style="background-color: #FF0000">b</span></code><span style="background-color: #FF0000">
- respectively.</span></p>
-<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="280">
- <tr>
- <td width="100%" colspan="3" align="center" height="19"><b><i>
- <span style="background-color: #FF0000">path non-member operators</span></i></b></td>
- </tr>
- <tr>
- <td width="20%" align="center" height="19"><i><b>
- <span style="background-color: #FF0000">Expression</span></b></i></td>
- <td width="25%" align="center" height="19"><i><b>
- <span style="background-color: #FF0000">Return type</span></b></i></td>
- <td width="55%" align="center" height="19"><i><b>
- <span style="background-color: #FF0000">Semantics</span></b></i></td>
- </tr>
- <tr>
- <td width="20%" align="center" height="30" valign="top"><code>
- <span style="background-color: #FF0000">a / b</span></code></td>
- <td width="25%" align="center" height="30" valign="top"><code>
- <span style="background-color: #FF0000">path<String, Traits></span></code></td>
- <td width="55%" height="30"><code><span style="background-color: #FF0000">
- path<String, Traits> tmp(a);<br>
- return tmp /= </span></code><i><b><span style="background-color: #FF0000">b'</span></b></i><code><span style="background-color: #FF0000">;</span></code></td>
- </tr>
- <tr>
- <td width="20%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">a < b</span></code></td>
- <td width="25%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">bool</span></code></td>
- <td width="55%" height="19"><code><span style="background-color: #FF0000">
- return lexicographical_compare(</span></code><span style="background-color: #FF0000"><i><b>a</b></i></span><code><span style="background-color: #FF0000"><i><b>'</b></i>.begin</span><span style="background-color: #FF0000">(), </span></code><i><b>
- <span style="background-color: #FF0000">a</span></b></i><code><span style="background-color: #FF0000"><i><b>'</b></i>.end</span><span style="background-color: #FF0000">(), </span></code><i><b>
- <span style="background-color: #FF0000">b'</span></b></i><code><span style="background-color: #FF0000">.begin</span><span style="background-color: #FF0000">(), </span></code><i><b>
- <span style="background-color: #FF0000">b'</span></b></i><code><span style="background-color: #FF0000">.end</span><span style="background-color: #FF0000">());</span></code></td>
- </tr>
- <tr>
- <td width="20%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">a == b</span></code></td>
- <td width="25%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">bool</span></code></td>
- <td width="55%" height="19"><code><span style="background-color: #FF0000">
- return !(</span></code><i><b><span style="background-color: #FF0000">a</span></b></i><code><i><b><span style="background-color: #FF0000">'</span></b></i><span style="background-color: #FF0000">
- < </span></code><i><b><span style="background-color: #FF0000">b'</span></b></i><code><span style="background-color: #FF0000">)
- && !(</span></code><i><b><span style="background-color: #FF0000">b'</span></b></i><code><span style="background-color: #FF0000">
- < </span></code><i><b><span style="background-color: #FF0000">a</span></b></i><code><i><b><span style="background-color: #FF0000">'</span></b></i><span style="background-color: #FF0000">);</span></code></td>
- </tr>
- <tr>
- <td width="20%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">a != b</span></code></td>
- <td width="25%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">bool</span></code></td>
- <td width="55%" height="19"><code><span style="background-color: #FF0000">
- return !(</span></code><i><b><span style="background-color: #FF0000">a</span></b></i><code><i><b><span style="background-color: #FF0000">'</span></b></i><span style="background-color: #FF0000">
- == </span></code><i><b><span style="background-color: #FF0000">b'</span></b></i><code><span style="background-color: #FF0000">);</span></code></td>
- </tr>
- <tr>
- <td width="20%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">a > b</span></code></td>
- <td width="25%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">bool</span></code></td>
- <td width="55%" height="19"><code><span style="background-color: #FF0000">
- return </span></code><i><b><span style="background-color: #FF0000">b'</span></b></i><code><span style="background-color: #FF0000">
- < </span></code><i><b><span style="background-color: #FF0000">a</span></b></i><code><i><b><span style="background-color: #FF0000">'</span></b></i><span style="background-color: #FF0000">;</span></code></td>
- </tr>
- <tr>
- <td width="20%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">a <= b</span></code></td>
- <td width="25%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">bool</span></code></td>
- <td width="55%" height="19"><code><span style="background-color: #FF0000">
- return !(</span></code><i><b><span style="background-color: #FF0000">b'</span></b></i><code><span style="background-color: #FF0000">
- < </span></code><i><b><span style="background-color: #FF0000">a</span></b></i><code><i><b><span style="background-color: #FF0000">'</span></b></i><span style="background-color: #FF0000">);</span></code></td>
- </tr>
- <tr>
- <td width="20%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">a >= b</span></code></td>
- <td width="25%" align="center" height="19" valign="top"><code>
- <span style="background-color: #FF0000">bool</span></code></td>
- <td width="55%" height="19"><code><span style="background-color: #FF0000">
- return !(</span></code><i><b><span style="background-color: #FF0000">a</span></b></i><code><i><b><span style="background-color: #FF0000">'</span></b></i><span style="background-color: #FF0000">
- < </span></code><i><b><span style="background-color: #FF0000">b'</span></b></i><code><span style="background-color: #FF0000">);</span></code></td>
- </tr>
-</table>
- <blockquote>
- <p><span style="background-color: #FF0000">[</span><i><span style="background-color: #FF0000">Note:</span></i><span style="background-color: #FF0000">
- </span> <a name="Path-equality"><span style="background-color: #FF0000">Path equality</span></a><span style="background-color: #FF0000"> and path
- equivalence have different semantics.</span></p>
- <p><span style="background-color: #FF0000">Equality is determined by </span> <i>
- <span style="background-color: #FF0000">path</span></i><span style="background-color: #FF0000">'s
- non-member </span> <code><a href="#operator-eq">
- <span style="background-color: #FF0000">operator==</span></a></code><span style="background-color: #FF0000">, which considers the two path's lexical representations
- only. Paths "abc" and "ABC" are never equal.</span></p>
- <p><span style="background-color: #FF0000">Equivalence is determined by the
- </span> equivalent()<span style="background-color: #FF0000">
- non-member function, which determines if two paths </span>
- resolve<span style="background-color: #FF0000"> to the same file system entity.
- Paths "abc"
- and "ABC" may or may not resolve to the same file, depending on the file
- system.</span></p>
- <p><span style="background-color: #FF0000">Programmers wishing to determine if two paths are "the same" must decide if
+ <pre>bool lexicographical_compare(path::iterator first1, path::iterator last1,
+ path::iterator first2, path::iterator last2)</pre>
+<blockquote>
+ <p><i>Returns:</i> <code>true</code> if the sequence of <code>native()</code>
+ strings for the elements defined by the range <code>[first1,last1)</code> is
+ lexicographically less than the sequence of <code>native()</code> strings for
+ the elements defined by the range <code>[first2,last2)</code>. Returns <code>
+ false</code> otherwise.</p>
+ <p><i>Remarks:</i> If two sequences have the same number of elements and their
+ corresponding elements are equivalent, then neither sequence is
+ lexicographically less than the other. If one sequence is a prefix of the
+ other, then the shorter sequence is lexicographically less than the longer
+ sequence. Otherwise, the lexicographical comparison of the sequences yields
+ the same result as the comparison of the first corresponding pair of elements
+ that are not equivalent.</p>
+ <pre> for ( ; first1 != last1 && first2 != last2 ; ++first1, ++first2) {
+ if (first1->native() < first2->native()) return true;
+ if (first2->native() < first1->native()) return false;
+ }
+ return first1 == last1 && first2 != last2;</pre>
+ <p>[<i>Note:</i> A <code>path</code> aware<code> lexicographical_compare</code>
+ is provided to avoid infinite recursion in <code>std::lexicographical_compare</code>
+ due to the <code>path</code> iterator's value type itself being <code>path</code>.
+ <i>--end note</i>]</p>
+</blockquote>
+<pre>bool operator< (const path& lhs, const path& rhs);</pre>
+<blockquote>
+ <p><i>Returns:</i> <code>return lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end())</code>.</p>
+</blockquote>
+<pre>bool operator<=(const path& lhs, const path& rhs);</pre>
+<blockquote>
+ <p><i>Returns:</i> <code>!(rhs < lhs)</code>.</p>
+</blockquote>
+<pre>bool operator> (const path& lhs, const path& rhs);</pre>
+<blockquote>
+ <p><i>Returns:</i> <code>rhs < lhs</code>.</p>
+</blockquote>
+<pre>bool operator>=(const path& lhs, const path& rhs);</pre>
+<blockquote>
+ <p><i>Returns:</i> <code>!(lhs < rhs)</code>.</p>
+</blockquote>
+<pre>bool operator==(const path& lhs, const path& rhs);</pre>
+<blockquote>
+ <p><i>Returns:</i> <code>!(lhs < rhs) && !(rhs < lhs)</code>.</p>
+ <p>[<i>Note:</i> Actual implementations may use an equivalent, but more
+ efficient, algorithm. <i>--end note</i>]</p>
+ <p>[<i>Note:</i> <a name="Path-equality">Path equality</a> and path
+ equivalence have different semantics.</p>
+ <p>Equality is determined by the <code>path</code>
+ non-member <code>operator==</code>, which considers the two path's lexical
+ representations only. Thus <code>path("foo") == "bar"</code> is never
+ <code>true</code>.</p>
+ <p>Equivalence is determined by the equivalent()
+ non-member function, which determines if two paths
+ resolve to the same file system entity.
+ Thus <code>equivalent("foo", "bar")</code> will be <code>true</code>
+ when both paths resolve to the same file.</p>
+ <p>Programmers wishing to determine if two paths are "the same" must decide if
"the same" means "the same representation" or "resolve to the same actual
- file", and choose the appropriate function accordingly. </span> <i>
- <span style="background-color: #FF0000">-- end note</span></i><span style="background-color: #FF0000">]</span></p>
+ file", and choose the appropriate function accordingly. <i>
+ -- end note</i>]</p>
+</blockquote>
+<pre>bool operator!=(const path& lhs, const path& rhs);</pre>
+<blockquote>
+ <p><i>Returns:</i> <code>!(lhs == rhs)</code>.</p>
+</blockquote>
+<pre>path operator/ (const path& lhs, const path& rhs);</pre>
+<blockquote>
+ <p><i>Returns:</i> <code>path(lhs) /= rhs</code>.</p>
</blockquote>
- <h4><a name="path-inserter-extractor"> <code>
- <span style="background-color: #FFFFFF">path</span></code><span style="background-color: #FFFFFF"> inserters
- and extractor</span></a><span style="background-color: #FFFFFF">s</span></h4>
+<h3> <a name="path-non-member-operators"><code><font size="4">path</font></code></a><a name="path-inserter-extractor"><span style="background-color: #FFFFFF"> inserters
+ and extractor</span></a><span style="background-color: #FFFFFF">s</span></h3>
<pre>std::ostream& operator<<(std::ostream & os, const path& p);</pre>
<blockquote>
<p><i><span style="background-color: #FFFFFF">Effects:</span></i><span style="background-color: #FFFFFF">
- <code>os << p.native_string();</code></span></p>
+ <code>os << p.string();</code></span></p>
<p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF">
</span> <code><span style="background-color: #FFFFFF">os</span></code></p>
</blockquote>
<pre>std::wostream& operator<<(std::wostream & os, const path& p);</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">
- <code>os << p.native_wstring();</code></span></p>
+ <code>os << p.wstring();</code></span></p>
<p style="font-size: 10pt"><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF">
</span><code><span style="background-color: #FFFFFF">os</span></code></p>
</blockquote>
@@ -3401,7 +3200,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 -->07 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32146" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->13 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32139" --></p>
</body>
Modified: sandbox/filesystem-v3/libs/filesystem/doc/tutorial.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/tutorial.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/tutorial.html 2010-01-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -530,14 +530,14 @@
localize()-----------: /foo/bar/baa.txt
...
observers, native format:
- native()---------: /foo/bar/baa.txt
- c_str()----------: /foo/bar/baa.txt
- native_string()--: /foo/bar/baa.txt
- native_wstring()-: /foo/bar/baa.txt
+ native()-------------: /foo/bar/baa.txt
+ c_str()--------------: /foo/bar/baa.txt
+ string()-------------: /foo/bar/baa.txt
+ wstring()------------: /foo/bar/baa.txt
observers, generic format:
- string()---------: /foo/bar/baa.txt
- wstring()--------: /foo/bar/baa.txt</pre>
+ generic_string()-----: /foo/bar/baa.txt
+ generic_wstring()----: /foo/bar/baa.txt</pre>
</td>
<td style="font-size: 10pt">
<pre>>path_info /foo/bar\baa.txt
@@ -547,14 +547,14 @@
localize()-----------: \foo\bar\baa.txt
...
observers, native format:
- native()---------: /foo/bar\baa.txt
- c_str()----------: /foo/bar\baa.txt
- native_string()--: /foo/bar\baa.txt
- native_wstring()-: /foo/bar\baa.txt
+ native()-------------: /foo/bar\baa.txt
+ c_str()--------------: /foo/bar\baa.txt
+ string()-------------: /foo/bar\baa.txt
+ wstring()------------: /foo/bar\baa.txt
observers, generic format:
- string()---------: /foo/bar/baa.txt
- wstring()--------: /foo/bar/baa.txt</pre>
+ generic_string()-----: /foo/bar/baa.txt
+ generic_wstring()----: /foo/bar/baa.txt</pre>
</td>
</tr>
</table>
@@ -599,14 +599,14 @@
<pre>$ ./path_info /foo/bar/baa.txt
...
decomposition:
- root_name()------:
- root_directory()-: /
- root_path()------: /
- relative_path()--: foo/bar/baa.txt
- parent_path()----: /foo/bar
- filename()-------: baa.txt
- stem()-----------: baa
- extension()------: .txt
+ root_name()----------:
+ root_directory()-----: /
+ root_path()----------: /
+ relative_path()------: foo/bar/baa.txt
+ parent_path()--------: /foo/bar
+ filename()-----------: baa.txt
+ stem()---------------: baa
+ extension()----------: .txt
query:
empty()--------------: false
@@ -624,14 +624,14 @@
<pre>>path_info /foo/bar/baa.txt
...
decomposition:
- root_name()------:
- root_directory()-: /
- root_path()------: /
- relative_path()--: foo/bar/baa.txt
- parent_path()----: /foo/bar
- filename()-------: baa.txt
- stem()-----------: baa
- extension()------: .txt
+ root_name()----------:
+ root_directory()-----: /
+ root_path()----------: /
+ relative_path()------: foo/bar/baa.txt
+ parent_path()--------: /foo/bar
+ filename()-----------: baa.txt
+ stem()---------------: baa
+ extension()----------: .txt
query:
empty()--------------: false
@@ -752,7 +752,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 -->09 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32150" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->12 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32137" --></p>
</body>
Modified: sandbox/filesystem-v3/libs/filesystem/example/error_demo.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/example/error_demo.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/example/error_demo.cpp 2010-01-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -116,7 +116,7 @@
// get status - no error_code
- cout << "\nstatus(\"" << p.native_string() << "\");\n";
+ cout << "\nstatus(\"" << p.string() << "\");\n";
threw_exception = false;
try { s = fs::status(p); }
@@ -131,14 +131,14 @@
// get status - with error_code
- cout << "\nstatus(\"" << p.native_string() << "\", ec);\n";
+ cout << "\nstatus(\"" << p.string() << "\", ec);\n";
s = fs::status(p, ec);
report_status(s);
report_error_code(ec);
// query existence - no error_code
- cout << "\nexists(\"" << p.native_string() << "\");\n";
+ cout << "\nexists(\"" << p.string() << "\");\n";
threw_exception = false;
try { b = fs::exists(p); }
@@ -157,7 +157,7 @@
// directory_iterator - no error_code
- cout << "\ndirectory_iterator(\"" << p.native_string() << "\");\n";
+ cout << "\ndirectory_iterator(\"" << p.string() << "\");\n";
threw_exception = false;
try { di = fs::directory_iterator(p); }
@@ -175,7 +175,7 @@
// directory_iterator - with error_code
- cout << "\ndirectory_iterator(\"" << p.native_string() << "\", ec);\n";
+ cout << "\ndirectory_iterator(\"" << p.string() << "\", ec);\n";
di = fs::directory_iterator(p, ec);
cout << (di == fs::directory_iterator() ? " Equal" : " Not equal")
<< " to the end iterator\n";
Modified: sandbox/filesystem-v3/libs/filesystem/example/path_info.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/example/path_info.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/example/path_info.cpp 2010-01-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -44,28 +44,28 @@
cout << "\nobservers, native format:" << endl;
#ifdef BOOST_POSIX_API
- cout << " native()---------: " << p.native() << endl;
- cout << " c_str()----------: " << p.c_str() << endl;
+ cout << " native()-------------: " << p.native() << endl;
+ cout << " c_str()--------------: " << p.c_str() << endl;
#else // BOOST_WINDOWS_API
- wcout << L" native()---------: " << p.native() << endl;
- wcout << L" c_str()----------: " << p.c_str() << endl;
+ wcout << L" native()-------------: " << p.native() << endl;
+ wcout << L" c_str()--------------: " << p.c_str() << endl;
#endif
- cout << " native_string()--: " << p.native_string() << endl;
- wcout << L" native_wstring()-: " << p.native_wstring() << endl;
+ cout << " string()-------------: " << p.string() << endl;
+ wcout << L" wstring()------------: " << p.wstring() << endl;
cout << "\nobservers, generic format:\n";
- cout << " string()---------: " << p.string() << endl;
- wcout << L" wstring()--------: " << p.wstring() << endl;
+ cout << " generic_string()-----: " << p.generic_string() << endl;
+ wcout << L" generic_wstring()----: " << p.generic_wstring() << endl;
cout << "\ndecomposition:\n";
- cout << " root_name()------: " << p.root_name() << '\n';
- cout << " root_directory()-: " << p.root_directory() << '\n';
- cout << " root_path()------: " << p.root_path() << '\n';
- cout << " relative_path()--: " << p.relative_path() << '\n';
- cout << " parent_path()----: " << p.parent_path() << '\n';
- cout << " filename()-------: " << p.filename() << '\n';
- cout << " stem()-----------: " << p.stem() << '\n';
- cout << " extension()------: " << p.extension() << '\n';
+ cout << " root_name()----------: " << p.root_name() << '\n';
+ cout << " root_directory()-----: " << p.root_directory() << '\n';
+ cout << " root_path()----------: " << p.root_path() << '\n';
+ cout << " relative_path()------: " << p.relative_path() << '\n';
+ cout << " parent_path()--------: " << p.parent_path() << '\n';
+ cout << " filename()-----------: " << p.filename() << '\n';
+ cout << " stem()---------------: " << p.stem() << '\n';
+ cout << " extension()----------: " << p.extension() << '\n';
cout << "\nquery:\n";
cout << " empty()--------------: " << say_what(p.empty()) << '\n';
Modified: sandbox/filesystem-v3/libs/filesystem/example/simple_ls.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/example/simple_ls.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/example/simple_ls.cpp 2010-01-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -34,14 +34,13 @@
if (!fs::exists(p))
{
- std::cout << "\nNot found: " << p.string() << std::endl;
+ std::cout << "\nNot found: " << p << std::endl;
return 1;
}
if (fs::is_directory(p))
{
- std::cout << "\nIn directory: "
- << p.string() << "\n\n";
+ std::cout << "\nIn directory: " << p << "\n\n";
fs::directory_iterator end_iter;
for (fs::directory_iterator dir_itr(p);
dir_itr != end_iter;
@@ -79,7 +78,7 @@
}
else // must be a file
{
- std::cout << "\nFound: " << p.string() << "\n";
+ std::cout << "\nFound: " << p << "\n";
}
return 0;
}
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 2010-01-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -1460,7 +1460,7 @@
m_status = m_symlink_status;
if (ec != 0) ec->clear();
}
- else m_status = detail::status(m_path, ec);
+ else m_status = detail::status(m_pathname, ec);
}
else if (ec != 0) ec->clear();
return m_status;
@@ -1470,7 +1470,7 @@
directory_entry::m_get_symlink_status(system::error_code* ec) const
{
if (!status_known(m_symlink_status))
- m_symlink_status = detail::symlink_status(m_path, ec);
+ m_symlink_status = detail::symlink_status(m_pathname, ec);
else if (ec != 0) ec->clear();
return m_symlink_status;
}
Modified: sandbox/filesystem-v3/libs/filesystem/src/path.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/path.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/path.cpp 2010-01-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -134,51 +134,51 @@
{
if (p.empty())
return *this;
- if (!is_separator(*p.m_path.begin()))
+ if (!is_separator(*p.m_pathname.begin()))
m_append_separator_if_needed();
- m_path += p.m_path;
+ m_pathname += p.m_pathname;
return *this;
}
# ifdef BOOST_WINDOWS_PATH
- const std::string path::native_string() const
+ const std::string path::string() const
{
std::string tmp;
- if (!m_path.empty())
- path_traits::convert(&*m_path.begin(), &*m_path.begin()+m_path.size(),
+ if (!m_pathname.empty())
+ path_traits::convert(&*m_pathname.begin(), &*m_pathname.begin()+m_pathname.size(),
tmp, codecvt());
return tmp;
}
void path::m_portable()
{
- for (string_type::iterator it = m_path.begin();
- it != m_path.end(); ++it)
+ for (string_type::iterator it = m_pathname.begin();
+ it != m_pathname.end(); ++it)
{
if (*it == L'\\')
*it = L'/';
}
}
- const std::string path::string() const
+ const std::string path::generic_string() const
{
path tmp(*this);
tmp.m_portable();
- return tmp.native_string();
+ return tmp.string();
}
- const std::wstring path::wstring() const
+ const std::wstring path::generic_wstring() const
{
path tmp(*this);
tmp.m_portable();
- return tmp.native_wstring();
+ return tmp.wstring();
}
path & path::localize()
{
- for (string_type::iterator it = m_path.begin();
- it != m_path.end(); ++it)
+ for (string_type::iterator it = m_pathname.begin();
+ it != m_pathname.end(); ++it)
{
if (*it == L'/')
*it = L'\\';
@@ -192,14 +192,14 @@
path::string_type::size_type path::m_append_separator_if_needed()
{
- if (!m_path.empty() &&
+ if (!m_pathname.empty() &&
# ifdef BOOST_WINDOWS_PATH
- *(m_path.end()-1) != colon &&
+ *(m_pathname.end()-1) != colon &&
# endif
- !is_separator(*(m_path.end()-1)))
+ !is_separator(*(m_pathname.end()-1)))
{
- string_type::size_type tmp(m_path.size());
- m_path += preferred_separator;
+ string_type::size_type tmp(m_pathname.size());
+ m_pathname += preferred_separator;
return tmp;
}
return 0;
@@ -210,12 +210,12 @@
void path::m_erase_redundant_separator(string_type::size_type sep_pos)
{
if (sep_pos // a separator was added
- && sep_pos < m_path.size() // and something was appended
- && (m_path[sep_pos+1] == separator // and it was also separator
+ && sep_pos < m_pathname.size() // and something was appended
+ && (m_pathname[sep_pos+1] == separator // and it was also separator
# ifdef BOOST_WINDOWS_PATH
- || m_path[sep_pos+1] == preferred_separator // or preferred_separator
+ || m_pathname[sep_pos+1] == preferred_separator // or preferred_separator
# endif
-)) { m_path.erase(sep_pos, 1); } // erase the added separator
+)) { m_pathname.erase(sep_pos, 1); } // erase the added separator
}
// decomposition -------------------------------------------------------------------//
@@ -223,7 +223,7 @@
path path::root_path() const
{
path temp(root_name());
- if (!root_directory().empty()) temp.m_path += root_directory().c_str();
+ if (!root_directory().empty()) temp.m_pathname += root_directory().c_str();
return temp;
}
@@ -231,14 +231,14 @@
{
iterator itr(begin());
- return (itr.m_pos != m_path.size()
+ return (itr.m_pos != m_pathname.size()
&& (
- (itr.m_element.m_path.size() > 1
- && is_separator(itr.m_element.m_path[0])
- && is_separator(itr.m_element.m_path[1])
+ (itr.m_element.m_pathname.size() > 1
+ && is_separator(itr.m_element.m_pathname[0])
+ && is_separator(itr.m_element.m_pathname[1])
)
# ifdef BOOST_WINDOWS_PATH
- || itr.m_element.m_path[itr.m_element.m_path.size()-1] == colon
+ || itr.m_element.m_pathname[itr.m_element.m_pathname.size()-1] == colon
# endif
))
? itr.m_element
@@ -247,40 +247,40 @@
path path::root_directory() const
{
- size_type pos(root_directory_start(m_path, m_path.size()));
+ size_type pos(root_directory_start(m_pathname, m_pathname.size()));
return pos == string_type::npos
? path()
- : path(m_path.c_str() + pos, m_path.c_str() + pos + 1);
+ : path(m_pathname.c_str() + pos, m_pathname.c_str() + pos + 1);
}
path path::relative_path() const
{
iterator itr(begin());
- for (; itr.m_pos != m_path.size()
- && (is_separator(itr.m_element.m_path[0])
+ for (; itr.m_pos != m_pathname.size()
+ && (is_separator(itr.m_element.m_pathname[0])
# ifdef BOOST_WINDOWS_PATH
- || itr.m_element.m_path[itr.m_element.m_path.size()-1] == colon
+ || itr.m_element.m_pathname[itr.m_element.m_pathname.size()-1] == colon
# endif
); ++itr) {}
- return path(m_path.c_str() + itr.m_pos);
+ return path(m_pathname.c_str() + itr.m_pos);
}
string_type::size_type path::m_parent_path_end() const
{
- size_type end_pos(filename_pos(m_path, m_path.size()));
+ size_type end_pos(filename_pos(m_pathname, m_pathname.size()));
- bool filename_was_separator(m_path.size()
- && is_separator(m_path[end_pos]));
+ bool filename_was_separator(m_pathname.size()
+ && is_separator(m_pathname[end_pos]));
// skip separators unless root directory
- size_type root_dir_pos(root_directory_start(m_path, end_pos));
+ size_type root_dir_pos(root_directory_start(m_pathname, end_pos));
for (;
end_pos > 0
&& (end_pos-1) != root_dir_pos
- && is_separator(m_path[end_pos-1])
+ && is_separator(m_pathname[end_pos-1])
;
--end_pos) {}
@@ -294,57 +294,57 @@
size_type end_pos(m_parent_path_end());
return end_pos == string_type::npos
? path()
- : path(m_path.c_str(), m_path.c_str() + end_pos);
+ : path(m_pathname.c_str(), m_pathname.c_str() + end_pos);
}
path& path::remove_filename()
{
- m_path.erase(m_parent_path_end());
+ m_pathname.erase(m_parent_path_end());
return *this;
}
path path::filename() const
{
- size_type pos(filename_pos(m_path, m_path.size()));
- return (m_path.size()
+ size_type pos(filename_pos(m_pathname, m_pathname.size()));
+ return (m_pathname.size()
&& pos
- && is_separator(m_path[pos])
- && is_non_root_separator(m_path, pos))
+ && is_separator(m_pathname[pos])
+ && is_non_root_separator(m_pathname, pos))
? dot_path
- : path(m_path.c_str() + pos);
+ : path(m_pathname.c_str() + pos);
}
path path::stem() const
{
path name(filename());
if (name == dot_path || name == dot_dot_path) return name;
- size_type pos(name.m_path.rfind(dot));
+ size_type pos(name.m_pathname.rfind(dot));
return pos == string_type::npos
? name
- : path(name.m_path.c_str(), name.m_path.c_str() + pos);
+ : path(name.m_pathname.c_str(), name.m_pathname.c_str() + pos);
}
path path::extension() const
{
path name(filename());
if (name == dot_path || name == dot_dot_path) return path();
- size_type pos(name.m_path.rfind(dot));
+ size_type pos(name.m_pathname.rfind(dot));
return pos == string_type::npos
? path()
- : path(name.m_path.c_str() + pos);
+ : path(name.m_pathname.c_str() + pos);
}
path & path::replace_extension(const path & source)
{
// erase existing extension if any
- size_type pos(m_path.rfind(dot));
+ size_type pos(m_pathname.rfind(dot));
if (pos != string_type::npos)
- m_path.erase(pos);
+ m_pathname.erase(pos);
// append source extension if any
- pos = source.m_path.rfind(dot);
+ pos = source.m_pathname.rfind(dot);
if (pos != string_type::npos)
- m_path += source.c_str() + pos;
+ m_pathname += source.c_str() + pos;
return *this;
}
@@ -354,7 +354,7 @@
path& path::m_normalize()
{
- if (m_path.empty()) return *this;
+ if (m_pathname.empty()) return *this;
path temp;
iterator start(begin());
@@ -391,15 +391,15 @@
{
temp.remove_filename();
// if not root directory, must also remove "/" if any
- if (temp.m_path.size() > 0
- && temp.m_path[temp.m_path.size()-1]
+ if (temp.m_pathname.size() > 0
+ && temp.m_pathname[temp.m_pathname.size()-1]
== separator)
{
string_type::size_type rds(
- root_directory_start(temp.m_path, temp.m_path.size()));
+ root_directory_start(temp.m_pathname, temp.m_pathname.size()));
if (rds == string_type::npos
- || rds != temp.m_path.size()-1)
- { temp.m_path.erase(temp.m_path.size()-1); }
+ || rds != temp.m_pathname.size()-1)
+ { temp.m_pathname.erase(temp.m_pathname.size()-1); }
}
iterator next(itr);
@@ -413,7 +413,7 @@
};
if (temp.empty()) temp /= dot_path;
- m_path = temp.m_path;
+ m_pathname = temp.m_pathname;
return *this;
}
@@ -597,10 +597,10 @@
iterator itr;
itr.m_path_ptr = this;
size_type element_size;
- first_element(m_path, itr.m_pos, element_size);
- itr.m_element = m_path.substr(itr.m_pos, element_size);
- if (itr.m_element.m_path == preferred_separator_string)
- itr.m_element.m_path = separator_string; // needed for Windows, harmless on POSIX
+ first_element(m_pathname, itr.m_pos, element_size);
+ itr.m_element = m_pathname.substr(itr.m_pos, element_size);
+ if (itr.m_element.m_pathname == preferred_separator_string)
+ itr.m_element.m_pathname = separator_string; // needed for Windows, harmless on POSIX
return itr;
}
@@ -608,53 +608,53 @@
{
iterator itr;
itr.m_path_ptr = this;
- itr.m_pos = m_path.size();
+ itr.m_pos = m_pathname.size();
return itr;
}
void path::m_path_iterator_increment(path::iterator & it)
{
- BOOST_ASSERT(it.m_pos < it.m_path_ptr->m_path.size() && "path::basic_iterator increment past end()");
+ BOOST_ASSERT(it.m_pos < it.m_path_ptr->m_pathname.size() && "path::basic_iterator increment past end()");
// increment to position past current element
- it.m_pos += it.m_element.m_path.size();
+ it.m_pos += it.m_element.m_pathname.size();
// if end reached, create end basic_iterator
- if (it.m_pos == it.m_path_ptr->m_path.size())
+ if (it.m_pos == it.m_path_ptr->m_pathname.size())
{
it.m_element.clear();
return;
}
// both POSIX and Windows treat paths that begin with exactly two separators specially
- bool was_net(it.m_element.m_path.size() > 2
- && is_separator(it.m_element.m_path[0])
- && is_separator(it.m_element.m_path[1])
- && !is_separator(it.m_element.m_path[2]));
+ bool was_net(it.m_element.m_pathname.size() > 2
+ && is_separator(it.m_element.m_pathname[0])
+ && is_separator(it.m_element.m_pathname[1])
+ && !is_separator(it.m_element.m_pathname[2]));
// process separator (Windows drive spec is only case not a separator)
- if (is_separator(it.m_path_ptr->m_path[it.m_pos]))
+ if (is_separator(it.m_path_ptr->m_pathname[it.m_pos]))
{
// detect root directory
if (was_net
# ifdef BOOST_WINDOWS_PATH
// case "c:/"
- || it.m_element.m_path[it.m_element.m_path.size()-1] == colon
+ || it.m_element.m_pathname[it.m_element.m_pathname.size()-1] == colon
# endif
)
{
- it.m_element.m_path = separator;
+ it.m_element.m_pathname = separator;
return;
}
// bypass separators
- while (it.m_pos != it.m_path_ptr->m_path.size()
- && is_separator(it.m_path_ptr->m_path[it.m_pos]))
+ while (it.m_pos != it.m_path_ptr->m_pathname.size()
+ && is_separator(it.m_path_ptr->m_pathname[it.m_pos]))
{ ++it.m_pos; }
// detect trailing separator, and treat it as ".", per POSIX spec
- if (it.m_pos == it.m_path_ptr->m_path.size()
- && is_non_root_separator(it.m_path_ptr->m_path, it.m_pos-1))
+ if (it.m_pos == it.m_path_ptr->m_pathname.size()
+ && is_non_root_separator(it.m_path_ptr->m_pathname, it.m_pos-1))
{
--it.m_pos;
it.m_element = dot_path;
@@ -663,9 +663,9 @@
}
// get next element
- size_type end_pos(it.m_path_ptr->m_path.find_first_of(separators, it.m_pos));
- if (end_pos == string_type::npos) end_pos = it.m_path_ptr->m_path.size();
- it.m_element = it.m_path_ptr->m_path.substr(it.m_pos, end_pos - it.m_pos);
+ size_type end_pos(it.m_path_ptr->m_pathname.find_first_of(separators, it.m_pos));
+ if (end_pos == string_type::npos) end_pos = it.m_path_ptr->m_pathname.size();
+ it.m_element = it.m_path_ptr->m_pathname.substr(it.m_pos, end_pos - it.m_pos);
}
void path::m_path_iterator_decrement(path::iterator & it)
@@ -675,10 +675,10 @@
size_type end_pos(it.m_pos);
// if at end and there was a trailing non-root '/', return "."
- if (it.m_pos == it.m_path_ptr->m_path.size()
- && it.m_path_ptr->m_path.size() > 1
- && is_separator(it.m_path_ptr->m_path[it.m_pos-1])
- && is_non_root_separator(it.m_path_ptr->m_path, it.m_pos-1)
+ if (it.m_pos == it.m_path_ptr->m_pathname.size()
+ && it.m_path_ptr->m_pathname.size() > 1
+ && is_separator(it.m_path_ptr->m_pathname[it.m_pos-1])
+ && is_non_root_separator(it.m_path_ptr->m_pathname, it.m_pos-1)
)
{
--it.m_pos;
@@ -686,32 +686,21 @@
return;
}
- size_type root_dir_pos(root_directory_start(it.m_path_ptr->m_path, end_pos));
+ size_type root_dir_pos(root_directory_start(it.m_path_ptr->m_pathname, end_pos));
// skip separators unless root directory
for (
;
end_pos > 0
&& (end_pos-1) != root_dir_pos
- && is_separator(it.m_path_ptr->m_path[end_pos-1])
+ && is_separator(it.m_path_ptr->m_pathname[end_pos-1])
;
--end_pos) {}
- it.m_pos = filename_pos(it.m_path_ptr->m_path, end_pos);
- it.m_element = it.m_path_ptr->m_path.substr(it.m_pos, end_pos - it.m_pos);
- if (it.m_element.m_path == preferred_separator_string)
- it.m_element.m_path = separator_string; // needed for Windows, harmless on POSIX
- }
-
- bool path::m_path_lex_compare(iterator first1, iterator last1,
- iterator first2, iterator last2)
- {
- for (; first1 != last1 && first2 != last2 ; ++first1, ++first2)
- {
- if (first1->m_path < first2->m_path) return true;
- if (first2->m_path < first1->m_path) return false;
- }
- return first1 == last1 && first2 != last2;
+ it.m_pos = filename_pos(it.m_path_ptr->m_pathname, end_pos);
+ it.m_element = it.m_path_ptr->m_pathname.substr(it.m_pos, end_pos - it.m_pos);
+ if (it.m_element.m_pathname == preferred_separator_string)
+ it.m_element.m_pathname = separator_string; // needed for Windows, harmless on POSIX
}
} // namespace filesystem
Modified: sandbox/filesystem-v3/libs/filesystem/src/unique_path.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/unique_path.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/unique_path.cpp 2010-01-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -106,7 +106,7 @@
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
+ std::wstring s (model.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
Modified: sandbox/filesystem-v3/libs/filesystem/test/deprecated_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/deprecated_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/deprecated_test.cpp 2010-01-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -28,11 +28,11 @@
void check(const fs::path & source,
const std::string & expected, int line)
{
- if (source.string()== expected) return;
+ if (source.generic_string()== expected) return;
++::boost::detail::test_errors();
- std::cout << '(' << line << ") source.native_string(): \"" << source.native_string()
+ std::cout << '(' << line << ") source.string(): \"" << source.string()
<< "\" != expected: \"" << expected
<< "\"" << std::endl;
}
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-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -57,7 +57,7 @@
void create_file(const fs::path & ph, const std::string & contents)
{
- std::ofstream f(ph.string().c_str());
+ std::ofstream f(ph.c_str());
if (!f)
throw fs::filesystem_error("operations_test create_file",
ph, error_code(errno, system_category));
@@ -66,7 +66,7 @@
void verify_file(const fs::path & ph, const std::string & expected)
{
- std::ifstream f(ph.string().c_str());
+ std::ifstream f(ph.c_str());
if (!f)
throw fs::filesystem_error("operations_test verify_file",
ph, error_code(errno, system_category));
@@ -685,7 +685,7 @@
catch (const fs::filesystem_error & x)
{
std::cout << x.what() << "\n\n"
- "***** Creating directory " << dir.string() << " failed. *****\n"
+ "***** Creating directory " << dir << " failed. *****\n"
"***** This is a serious error that will prevent further tests *****\n"
"***** from returning useful results. Further testing is aborted. *****\n\n";
std::exit(1);
@@ -694,7 +694,7 @@
catch (...)
{
std::cout << "\n\n"
- "***** Creating directory " << dir.string() << " failed. *****\n"
+ "***** Creating directory " << dir << " failed. *****\n"
"***** This is a serious error that will prevent further tests *****\n"
"***** from returning useful results. Further testing is aborted. *****\n\n";
std::exit(1);
@@ -733,7 +733,7 @@
BOOST_TEST(fs::current_path() != dir);
// make sure the overloads work
- fs::current_path(dir.string().c_str());
+ fs::current_path(dir.c_str());
BOOST_TEST(fs::current_path() == dir);
BOOST_TEST(fs::current_path() != original_dir);
fs::current_path(original_dir.string());
@@ -1071,11 +1071,11 @@
== fs::initial_path());
BOOST_TEST(fs::system_complete(fs::path(fs::initial_path().root_name().string()
+ "foo")).string() == fs::initial_path() / "foo");
- BOOST_TEST(fs::system_complete(fs::path("c:/")).string()
+ BOOST_TEST(fs::system_complete(fs::path("c:/")).generic_string()
== "c:/");
- BOOST_TEST(fs::system_complete(fs::path("c:/foo")).string()
+ BOOST_TEST(fs::system_complete(fs::path("c:/foo")).generic_string()
== "c:/foo");
- BOOST_TEST(fs::system_complete(fs::path("//share")).string()
+ BOOST_TEST(fs::system_complete(fs::path("//share")).generic_string()
== "//share");
} // Windows
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 2010-01-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -40,7 +40,7 @@
void check(const fs::path & source,
const std::string & expected, const char* file, int line)
{
- if (source.native_string() == expected)
+ if (source.string() == expected)
return;
std::cout << file
@@ -92,8 +92,8 @@
//BOOST_TEST(std::strcmp(ex.what(),
// "string-1: Unknown error: \"p1\", \"p2\"") == 0);
BOOST_TEST(ex.code() == ec);
- BOOST_TEST(ex.path1().string() == "p1");
- BOOST_TEST(ex.path2().string() == "p2");
+ BOOST_TEST(ex.path1() == "p1");
+ BOOST_TEST(ex.path2() == "p2");
}
}
@@ -398,11 +398,11 @@
PATH_CHECK(path("") / "..", "..");
if (platform == "Windows")
{
- BOOST_TEST((b / a).native_string() == "b\\a");
- BOOST_TEST((bs / a).native_string() == "b\\a");
- BOOST_TEST((bcs / a).native_string() == "b\\a");
- BOOST_TEST((b / as).native_string() == "b\\a");
- BOOST_TEST((b / acs).native_string() == "b\\a");
+ BOOST_TEST((b / a).string() == "b\\a");
+ BOOST_TEST((bs / a).string() == "b\\a");
+ BOOST_TEST((bcs / a).string() == "b\\a");
+ BOOST_TEST((b / as).string() == "b\\a");
+ BOOST_TEST((b / acs).string() == "b\\a");
PATH_CHECK(path("a") / "b", "a\\b");
PATH_CHECK(path("..") / "", "..");
PATH_CHECK(path("foo") / path("bar"), "foo\\bar"); // path arg
@@ -443,7 +443,7 @@
PATH_CHECK(path(".") / ".." / ".", ".\\..\\.");
PATH_CHECK(path("..") / "." / ".", "..\\.\\.");
}
- else
+ else // POSIX
{
BOOST_TEST((b / a).string() == "b/a");
BOOST_TEST((bs / a).string() == "b/a");
@@ -596,7 +596,7 @@
path p10 ("c:\\file");
path p11 ("c:/file");
// check each overload
- BOOST_TEST(p10.string() == p11.string());
+ BOOST_TEST(p10.generic_string() == p11.generic_string());
BOOST_TEST(p10 == p11);
BOOST_TEST(p10 == p11.string());
BOOST_TEST(p10 == p11.string().c_str());
@@ -611,7 +611,7 @@
BOOST_TEST(L"c:\\file" == p11);
BOOST_TEST(L"c:/file" == p11);
- BOOST_TEST(!(p10.string() != p11.string()));
+ BOOST_TEST(!(p10.generic_string() != p11.generic_string()));
BOOST_TEST(!(p10 != p11));
BOOST_TEST(!(p10 != p11.string()));
BOOST_TEST(!(p10 != p11.string().c_str()));
@@ -641,7 +641,7 @@
BOOST_TEST(!(L"c:\\file" < p11));
BOOST_TEST(!(L"c:/file" < p11));
- BOOST_TEST(!(p10.string() > p11.string()));
+ BOOST_TEST(!(p10.generic_string() > p11.generic_string()));
BOOST_TEST(!(p10 > p11));
BOOST_TEST(!(p10 > p11.string()));
BOOST_TEST(!(p10 > p11.string().c_str()));
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-13 10:54:36 EST (Wed, 13 Jan 2010)
@@ -61,8 +61,8 @@
++::boost::detail::test_errors();
std::cout << file;
- std::wcout << L'(' << line << L"): source.native_wstring(): \""
- << source.native_wstring()
+ std::wcout << L'(' << line << L"): source.wstring(): \""
+ << source.wstring()
<< L"\" != expected: \"" << expected
<< L"\"\n" ;
}
@@ -257,10 +257,10 @@
path p0("abc");
CHECK(p0.native().size() == 3);
- CHECK(p0.native_string() == "abc");
- CHECK(p0.native_string().size() == 3);
- CHECK(p0.native_wstring() == L"abc");
- CHECK(p0.native_wstring().size() == 3);
+ CHECK(p0.string() == "abc");
+ CHECK(p0.string().size() == 3);
+ CHECK(p0.wstring() == L"abc");
+ CHECK(p0.wstring().size() == 3);
# ifdef BOOST_WINDOWS_PATH
@@ -268,14 +268,15 @@
CHECK(std::wstring(p.c_str()) == L"abc\\def/ghi");
- CHECK(p.native_string() == "abc\\def/ghi");
- CHECK(p.native_wstring() == L"abc\\def/ghi");
+ CHECK(p.string() == "abc\\def/ghi");
+ CHECK(p.wstring() == L"abc\\def/ghi");
- CHECK(p.string() == "abc/def/ghi");
- CHECK(p.wstring() == L"abc/def/ghi");
+ CHECK(p.generic_string() == "abc/def/ghi");
+ CHECK(p.generic_wstring() == L"abc/def/ghi");
- //CHECK(p.preferred().string() == "abc\\def\\ghi");
- //CHECK(p.preferred().wstring() == L"abc\\def\\ghi");
+ CHECK(p.generic_string<string>() == "abc/def/ghi");
+ CHECK(p.generic_string<wstring>() == L"abc/def/ghi");
+ CHECK(p.generic_string<path::string_type>() == L"abc/def/ghi");
# else // BOOST_POSIX_PATH
@@ -283,14 +284,15 @@
CHECK(string(p.c_str()) == "abc\\def/ghi");
- CHECK(p.native_string() == "abc\\def/ghi");
- CHECK(p.native_wstring() == L"abc\\def/ghi");
-
CHECK(p.string() == "abc\\def/ghi");
CHECK(p.wstring() == L"abc\\def/ghi");
- //CHECK(p.preferred().string() == "abc\\def/ghi");
- //CHECK(p.preferred().wstring() == L"abc\\def/ghi");
+ CHECK(p.generic_string() == "abc\\def/ghi");
+ CHECK(p.generic_wstring() == L"abc\\def/ghi");
+
+ CHECK(p.generic_string<string>() == "abc\\def/ghi");
+ CHECK(p.generic_string<wstring>() == L"abc\\def/ghi");
+ CHECK(p.generic_string<path::string_type>() == "abc\\def/ghi");
# endif
}
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