Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63500 - in trunk: boost/filesystem/v3 libs/filesystem/v3/doc libs/filesystem/v3/test
From: bdawes_at_[hidden]
Date: 2010-07-02 14:54:56


Author: bemandawes
Date: 2010-07-01 14:55:41 EDT (Thu, 01 Jul 2010)
New Revision: 63500
URL: http://svn.boost.org/trac/boost/changeset/63500

Log:
Deprecate initial_path as too error prone without C++ runtime support.
Text files modified:
   trunk/boost/filesystem/v3/operations.hpp | 5 ++---
   trunk/libs/filesystem/v3/doc/deprecated.html | 22 ++++++++++++++++++++--
   trunk/libs/filesystem/v3/doc/reference.html | 38 ++++++++++----------------------------
   trunk/libs/filesystem/v3/test/deprecated_test.cpp | 2 ++
   trunk/libs/filesystem/v3/test/operations_test.cpp | 35 ++++++++++++++++++-----------------
   5 files changed, 52 insertions(+), 50 deletions(-)

Modified: trunk/boost/filesystem/v3/operations.hpp
==============================================================================
--- trunk/boost/filesystem/v3/operations.hpp (original)
+++ trunk/boost/filesystem/v3/operations.hpp 2010-07-01 14:55:41 EDT (Thu, 01 Jul 2010)
@@ -353,14 +353,13 @@
   inline
   boost::uintmax_t hard_link_count(const path& p, system::error_code& ec)
                                        {return detail::hard_link_count(p, &ec);}
+# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
   inline
   path initial_path() {return detail::initial_path();}
 
   inline
   path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
 
-# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
- // support legacy initial_path<...>()
   template <class Path>
   path initial_path() {return initial_path();}
   template <class Path>
@@ -942,7 +941,6 @@
     using filesystem3::file_type;
     using filesystem3::filesystem_error;
     using filesystem3::hard_link_count;
- using filesystem3::initial_path;
     using filesystem3::is_directory;
     using filesystem3::is_directory;
     using filesystem3::is_empty;
@@ -969,6 +967,7 @@
     using filesystem3::type_unknown;
     using filesystem3::unique_path;
 # ifndef BOOST_FILESYSTEM_NO_DEPRECATED
+ using filesystem3::initial_path;
     using filesystem3::is_regular;
     using filesystem3::status_unknown;
     using filesystem3::symbolic_link_exists;

Modified: trunk/libs/filesystem/v3/doc/deprecated.html
==============================================================================
--- trunk/libs/filesystem/v3/doc/deprecated.html (original)
+++ trunk/libs/filesystem/v3/doc/deprecated.html 2010-07-01 14:55:41 EDT (Thu, 01 Jul 2010)
@@ -43,7 +43,7 @@
 The deprecated names and other workarounds can be suppressed by defining macro <code>
 BOOST_FILESYSTEM_NO_DEPRECATED</code>, and this is recommended for all new code.</p>
 <p style="font-size: 10pt">In the table, &#10004; indicates a synonym or other
-workaround is provide unless <code>
+workaround is provided unless <code>
 BOOST_FILESYSTEM_NO_DEPRECATED</code> is defined.</p>
 <table border="1" cellpadding="5" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111">
   <tr>
@@ -250,6 +250,16 @@
     <td style="font-size: 10pt" valign="top">
     <code>operations.hpp</code></td>
     <td style="font-size: 10pt" valign="top">
+ <code>initial_path()</code></td>
+ <td style="font-size: 10pt" valign="top">
+ &#10004;</td>
+ <td style="font-size: 10pt" valign="top">
+ <i>Function removed</i></td>
+ </tr>
+ <tr>
+ <td style="font-size: 10pt" valign="top">
+ <code>operations.hpp</code></td>
+ <td style="font-size: 10pt" valign="top">
     <code>is_regular(file_status f)</code></td>
     <td style="font-size: 10pt" valign="top">
     &#10004;</td>
@@ -338,9 +348,17 @@
   </tr>
 </table>
 
+<h2>Deprecation rationale</h2>
+<h3><code>initial_path</code> function</h3>
+<p dir="ltr">Full implementation of <code>initial_path()</code> would require
+support from the C++ runtime startup code, and that doesn't seem likely to
+happen. Depending on the user to call <code>initial_path()</code> at the
+beginning of <code>main()</code> is too error prone.&nbsp; An equivalent
+function can trivially be provided by a user.</p>
+
 <hr>
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->04 June, 2010<!--webbot bot="Timestamp" endspan i-checksum="19844" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->01 July, 2010<!--webbot bot="Timestamp" endspan i-checksum="21054" --></p>
 
 <p>&copy; Copyright Beman Dawes, 2002-2005, 2010</p>
 <p> Use, modification, and distribution are subject to the Boost Software

Modified: trunk/libs/filesystem/v3/doc/reference.html
==============================================================================
--- trunk/libs/filesystem/v3/doc/reference.html (original)
+++ trunk/libs/filesystem/v3/doc/reference.html 2010-07-01 14:55:41 EDT (Thu, 01 Jul 2010)
@@ -97,8 +97,7 @@
 &nbsp;&nbsp;&nbsp;&nbsp exists<br>
 &nbsp;&nbsp;&nbsp;&nbsp equivalent<br>
 &nbsp;&nbsp;&nbsp;&nbsp file_size<br>
-&nbsp;&nbsp;&nbsp;&nbsp initial_path<br>
-&nbsp;&nbsp;&nbsp;&nbsp is_directory<br>
+&nbsp;&nbsp;&nbsp;&nbsp is_directory<br>
 &nbsp;&nbsp;&nbsp;&nbsp is_empty<br>
 &nbsp;&nbsp;&nbsp;&nbsp is_other<br>
 &nbsp;&nbsp;&nbsp;&nbsp is_regular_file<br>
@@ -368,9 +367,6 @@
       <span style="background-color: #FFFFFF; ">uintmax_t</span> file_size(const path&amp; p);
       <span style="background-color: #FFFFFF; ">uintmax_t</span> file_size(const path&amp; p, system::error_code&amp; ec);
 
- const path&amp; initial_path();
- const path&amp; initial_path(system::error_code&amp; ec);
-
       bool is_directory(file_status s);
       bool is_directory(const path&amp; p);
       bool is_directory(const path&amp; p, system::error_code&amp; ec);
@@ -1989,12 +1985,12 @@
   <p><i>Throws:</i> As specified in
   <a href="#Error-reporting">
   Error reporting</a>.</p>
- <p>[<i>Note:</i> The current path as returned by many operating systems is a
- dangerous global variable. It may be changed unexpectedly by a third-party or
- system library functions, or by another thread. For a safer alternative,
- see <code>initial_path()</code>. The <code>
+ <p>[<i>Note: </i>The <code>
   current_path()</code> name was chosen to emphasize that the return is a
- path, not just a single directory name. <i>-- end note</i>]</p>
+ path, not just a single directory name.</p>
+ <p>The current path as returned by many operating systems is a dangerous
+ global variable. It may be changed unexpectedly by a third-party or system
+ library functions, or by another thread.&nbsp; <i>-- end note</i>]</p>
 </blockquote>
 <pre>void current_path(const path&amp; p);
 void current_path(const path&amp; p, system::error_code&amp; ec);</pre>
@@ -2009,6 +2005,9 @@
 <p><i>Throws:</i> As specified in
 <a href="#Error-reporting">
 Error reporting</a>.</p>
+ <p>[<i>Note: </i>The current path for many operating systems is a dangerous
+ global state. It may be changed unexpectedly by a third-party or system
+ library functions, or by another thread.&nbsp; <i>-- end note</i>]</p>
 </blockquote>
 <pre><span style="background-color: #FFFFFF">bool <a name="exists">exists</a>(file_status s);</span></pre>
 <blockquote>
@@ -2075,23 +2074,6 @@
   <a href="#Error-reporting">
   Error reporting</a>.</p>
 </blockquote>
-<pre>const path&amp; <a name="initial_path">initial_path</a>();
-const path&amp; <a name="initial_path2">initial_path</a>(system::error_code&amp; ec);</pre>
-<blockquote>
- <p><i>Returns:</i> <code>current_path()</code> at the time of entry to <code>
- main()</code>.</p>
- <p><i>Throws:</i> Nothing.</p>
- <p>[<i>Note:</i> These semantics turn a dangerous global variable into a safer
- global constant. <i>--end note</i>]</p>
- <p>[<i>Note:</i> Full implementation requires runtime library support.
- Implementations which cannot provide runtime library support are encouraged to
- instead store the value of <code>current_path()</code> at the first call of
- <code>initial_path</code><code>()</code>, and
- return this value for all subsequent calls. Programs using
- <code>initial_path</code><code>()</code> are
- encouraged to call it immediately on entrance to <code>main()</code> so that
- they will work correctly with such partial implementations. <i>--end note</i>]</p>
-</blockquote>
 <pre><span style="background-color: #FFFFFF">bool </span><code><span style="background-color: #FFFFFF"><a name="is_directory">is_directory</a></span></code><span style="background-color: #FFFFFF">(file_status s);</span></pre>
 <blockquote>
   <p><i><span style="background-color: #FFFFFF">Returns:</span></i><span style="background-color: #FFFFFF"> </span>
@@ -3077,7 +3059,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 -->24 June 2010<!--webbot bot="Timestamp" endspan i-checksum="17552" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->01 July 2010<!--webbot bot="Timestamp" endspan i-checksum="18760" --></p>
 
 </body>
 

Modified: trunk/libs/filesystem/v3/test/deprecated_test.cpp
==============================================================================
--- trunk/libs/filesystem/v3/test/deprecated_test.cpp (original)
+++ trunk/libs/filesystem/v3/test/deprecated_test.cpp 2010-07-01 14:55:41 EDT (Thu, 01 Jul 2010)
@@ -194,6 +194,8 @@
                : "POSIX";
   std::cout << "Platform is " << platform << '\n';
 
+ BOOST_TEST(fs::initial_path() == fs::current_path());
+
   //path::default_name_check(fs::no_check);
 
   fs::directory_entry de("foo/bar");

Modified: trunk/libs/filesystem/v3/test/operations_test.cpp
==============================================================================
--- trunk/libs/filesystem/v3/test/operations_test.cpp (original)
+++ trunk/libs/filesystem/v3/test/operations_test.cpp 2010-07-01 14:55:41 EDT (Thu, 01 Jul 2010)
@@ -58,6 +58,7 @@
   std::string platform(BOOST_PLATFORM);
   bool report_throws;
   bool cleanup = true;
+ fs::path init_path(fs::current_path());
   fs::directory_iterator end_itr;
   fs::path dir;
   fs::path d1;
@@ -1066,25 +1067,25 @@
         && dir.string()[1] == ':'); // verify path includes drive
 
       BOOST_TEST(fs::system_complete("").empty());
- BOOST_TEST(fs::system_complete("/") == fs::initial_path().root_path());
+ BOOST_TEST(fs::system_complete("/") == init_path.root_path());
       BOOST_TEST(fs::system_complete("foo")
- == fs::initial_path() / "foo");
+ == init_path / "foo");
 
       fs::path p1(fs::system_complete("/foo"));
       BOOST_TEST_EQ(p1.string().size(), 6U); // this failed during v3 development due to bug
       std::string s1(p1.string() );
- std::string s2(fs::initial_path().root_path().string()+"foo");
+ std::string s2(init_path.root_path().string()+"foo");
       BOOST_TEST_EQ(s1, s2);
 
- BOOST_TEST(fs::path("x:/").make_absolute(fs::initial_path()).string()
+ BOOST_TEST(fs::path("x:/").make_absolute(init_path).string()
         == "x:/");
- BOOST_TEST(fs::path("x:/foo").make_absolute(fs::initial_path()).string()
+ BOOST_TEST(fs::path("x:/foo").make_absolute(init_path).string()
         == "x:/foo");
 
- BOOST_TEST(fs::system_complete(fs::path(fs::initial_path().root_name()))
- == 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(init_path.root_name()))
+ == init_path);
+ BOOST_TEST(fs::system_complete(fs::path(init_path.root_name().string()
+ + "foo")).string() == init_path / "foo");
       BOOST_TEST(fs::system_complete(fs::path("c:/")).generic_string()
         == "c:/");
       BOOST_TEST(fs::system_complete(fs::path("c:/foo")).generic_string()
@@ -1097,12 +1098,12 @@
     {
       std::cout << "POSIX specific tests..." << std::endl;
       BOOST_TEST(fs::system_complete("").empty());
- BOOST_TEST(fs::initial_path().root_path().string() == "/");
+ BOOST_TEST(init_path.root_path().string() == "/");
       BOOST_TEST(fs::system_complete("/").string() == "/");
       BOOST_TEST(fs::system_complete("foo").string()
- == fs::initial_path().string()+"/foo");
+ == init_path.string()+"/foo");
       BOOST_TEST(fs::system_complete("/foo").string()
- == fs::initial_path().root_path().string()+"foo");
+ == init_path.root_path().string()+"foo");
     } // POSIX
   }
 
@@ -1112,12 +1113,12 @@
   {
     std::cout << "initial_tests..." << std::endl;
 
- std::cout << " initial_path().string() is\n \""
- << fs::initial_path().string()
+ std::cout << " current_path().string() is\n \""
+ << init_path.string()
               << "\"\n\n";
- BOOST_TEST(fs::initial_path().is_absolute());
+ BOOST_TEST(init_path.is_absolute());
     BOOST_TEST(fs::current_path().is_absolute());
- BOOST_TEST(fs::initial_path().string()
+ BOOST_TEST(init_path.string()
       == fs::current_path().string());
   }
 
@@ -1205,7 +1206,7 @@
 # endif
   std::cout << "API is " << platform << std::endl;
 
- dir = fs::initial_path() / temp_dir_name;
+ dir = init_path / temp_dir_name;
 
   if (fs::exists(dir))
   {


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