Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56952 - in sandbox/filesystem-v3: boost/filesystem libs/filesystem/doc libs/filesystem/src libs/filesystem/test
From: bdawes_at_[hidden]
Date: 2009-10-17 10:51:37


Author: bemandawes
Date: 2009-10-17 10:51:36 EDT (Sat, 17 Oct 2009)
New Revision: 56952
URL: http://svn.boost.org/trac/boost/changeset/56952

Log:
Rename file_size() setter to resize_file(), as suggested by Scott McMurray
Text files modified:
   sandbox/filesystem-v3/boost/filesystem/operations.hpp | 31 ++++++++++++-------------------
   sandbox/filesystem-v3/libs/filesystem/doc/reference.html | 25 +++++++++++++------------
   sandbox/filesystem-v3/libs/filesystem/src/operations.cpp | 18 +++++++++---------
   sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp | 16 ++++++++--------
   4 files changed, 42 insertions(+), 48 deletions(-)

Modified: sandbox/filesystem-v3/boost/filesystem/operations.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/operations.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/operations.hpp 2009-10-17 10:51:36 EDT (Sat, 17 Oct 2009)
@@ -167,6 +167,7 @@
 // in alphabetical order, unless otherwise noted //
 // //
 //--------------------------------------------------------------------------------------//
+
   BOOST_FILESYSTEM_DECL // declaration must precede complete()
   path initial_path( system::error_code & ec = throws() );
 
@@ -197,8 +198,7 @@
                   system::error_code & ec = throws() );
 
   inline
- void copy_file( const path & from, const path & to,
- system::error_code & ec = throws() )
+ void copy_file( const path & from, const path & to, system::error_code & ec = throws() )
     { copy_file( from, to, copy_option::fail_if_exists, ec ); }
 
   BOOST_FILESYSTEM_DECL
@@ -206,8 +206,7 @@
                      system::error_code & ec = throws() );
 
   BOOST_FILESYSTEM_DECL
- bool create_directories( const path & p/*,
- system::error_code & ec = throws()*/ );
+ bool create_directories( const path & p );
 
   BOOST_FILESYSTEM_DECL
   bool create_directory( const path & p, system::error_code & ec = throws() );
@@ -231,15 +230,10 @@
   void current_path( const path & p, system::error_code & ec = throws() );
 
   BOOST_FILESYSTEM_DECL
- bool equivalent( const path & p1, const path & p2,
- system::error_code & ec = throws() );
+ bool equivalent( const path & p1, const path & p2, system::error_code & ec = throws() );
 
   BOOST_FILESYSTEM_DECL
- boost::uintmax_t file_size( const path & p,
- system::error_code & ec = throws() );
-
- BOOST_FILESYSTEM_DECL
- void file_size( const path & p, uintmax_t size, system::error_code & ec = throws() );
+ boost::uintmax_t file_size( const path & p, system::error_code & ec = throws() );
 
   BOOST_FILESYSTEM_DECL
   boost::uintmax_t hard_link_count( const path & p, system::error_code & ec = throws() );
@@ -247,8 +241,7 @@
   // initial_path() declaration precedes complete()
 
   BOOST_FILESYSTEM_DECL
- std::time_t last_write_time( const path & p,
- system::error_code & ec = throws() );
+ std::time_t last_write_time( const path & p, system::error_code & ec = throws() );
 
   BOOST_FILESYSTEM_DECL
   void last_write_time( const path & p, const std::time_t new_time,
@@ -262,13 +255,13 @@
   bool remove( const path & p, system::error_code & ec = throws() );
 
   BOOST_FILESYSTEM_DECL
- boost::uintmax_t remove_all( const path & p,
- system::error_code & ec = throws() );
-
-
+ boost::uintmax_t remove_all( const path & p, system::error_code & ec = throws() );
+
   BOOST_FILESYSTEM_DECL
- void rename( const path & from, const path & to,
- system::error_code & ec = throws() );
+ void rename( const path & from, const path & to, system::error_code & ec = throws() );
+
+ BOOST_FILESYSTEM_DECL // name suggested by Scott McMurray
+ void resize_file( const path & p, uintmax_t size, system::error_code & ec = throws() );
 
   BOOST_FILESYSTEM_DECL
   space_info space( const path & p, system::error_code & ec = throws() );

Modified: sandbox/filesystem-v3/libs/filesystem/doc/reference.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/reference.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/reference.html 2009-10-17 10:51:36 EDT (Sat, 17 Oct 2009)
@@ -107,7 +107,7 @@
 &nbsp;&nbsp;&nbsp;&nbsp current_path<br>
 &nbsp;&nbsp;&nbsp;&nbsp exists<br>
 &nbsp;&nbsp;&nbsp;&nbsp equivalent<br>
-&nbsp;&nbsp;&nbsp;&nbsp file_size<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_empty<br>
@@ -118,6 +118,7 @@
 &nbsp;&nbsp;&nbsp;&nbsp remove<br>
 &nbsp;&nbsp;&nbsp;&nbsp remove_all<br>
 &nbsp;&nbsp;&nbsp;&nbsp rename<br>
+&nbsp;&nbsp;&nbsp;&nbsp; resize_file<br>
 &nbsp;&nbsp;&nbsp;&nbsp space<br>
 &nbsp;&nbsp;&nbsp;&nbsp status<br>
 &nbsp;&nbsp;&nbsp;&nbsp status_known<br>
@@ -2150,16 +2151,6 @@
   <p style="font-size: 10pt"><i>Throws:</i> <code>filesystem_error</code><span style="background-color: #FFFFFF">
   </span>if <code>!exists(p) || !is_regular_file(p)</code>.</p>
 </blockquote>
-<pre>void <a name="file_size">file_size</a>(const path&amp; p, <span style="background-color: #FFFFFF; ">uintmax_t new_size, </span>system::error_code&amp; ec=throws());</pre>
-<blockquote>
-<p><i>Postcondition:</i> <code>file_size() == new_size</code>.</p>
- <p style="font-size: 10pt"><i>Throws:</i> <code>filesystem_error</code><span style="background-color: #FFFFFF">
- </span>if <code>!exists(p) || !is_regular_file(p)</code>.</p>
- <p style="font-size: 10pt"><i>Remarks:</i> Achieves its postcondition as if by
- POSIX <code>
- <a href="http://www.opengroup.org/onlinepubs/000095399/functions/truncate.html">
- truncate()</a></code>.</p>
-</blockquote>
 <pre>const path&amp; <a name="initial_path">initial_path</a>(system::error_code&amp; ec=throws());</pre>
 <blockquote>
   <p><i>Returns:</i> <code>current_path()</code> at the time of entry to <code>
@@ -2283,6 +2274,16 @@
   existing file, it is removed. A symbolic link is itself renamed, rather than
   the file it resolves to being renamed. <i>-- end note</i>]</p>
 </blockquote>
+<pre>void <a name="resize_file">resize_file</a>(const path&amp; p, <span style="background-color: #FFFFFF; ">uintmax_t new_size, </span>system::error_code&amp; ec=throws());</pre>
+<blockquote>
+<p><i>Postcondition:</i> <code>file_size() == new_size</code>.</p>
+ <p style="font-size: 10pt"><i>Throws:</i> <code>filesystem_error</code><span style="background-color: #FFFFFF">
+ </span>if <code>!exists(p) || !is_regular_file(p)</code>.</p>
+ <p style="font-size: 10pt"><i>Remarks:</i> Achieves its postcondition as if by
+ POSIX <code>
+ <a href="http://www.opengroup.org/onlinepubs/000095399/functions/truncate.html">
+ truncate()</a></code>.</p>
+</blockquote>
 <pre><span style="background-color: #FFFFFF">space_info <a name="space">space</a>(const path&amp; p</span>, system::error_code&amp; ec=throws()<span style="background-color: #FFFFFF">);</span></pre>
 <blockquote>
   <p><span style="background-color: #FFFFFF"><i>Returns:</i> An object of type <code>
@@ -3150,7 +3151,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 -->16 October 2009<!--webbot bot="Timestamp" endspan i-checksum="32670" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->17 October 2009<!--webbot bot="Timestamp" endspan i-checksum="32672" --></p>
 
 </body>
 

Modified: sandbox/filesystem-v3/libs/filesystem/src/operations.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/operations.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/operations.cpp 2009-10-17 10:51:36 EDT (Sat, 17 Oct 2009)
@@ -137,7 +137,7 @@
          || ::mkdir( to.c_str(),from_stat.st_mode ) != 0))
 # define BOOST_COPY_FILE(F,T,FailIfExistsBool) copy_file_api(F, T, FailIfExistsBool)
 # define BOOST_MOVE_FILE(F,T) (::rename(F, T) == 0)
-# define BOOST_SET_FILE_SIZE(P,SZ) (::truncate( P, SZ ) == 0)
+# define BOOST_RESIZE_FILE(P,SZ) (::truncate( P, SZ ) == 0)
 
 # define BOOST_ERROR_NOT_SUPPORTED ENOSYS
 # define BOOST_ERROR_ALREADY_EXISTS EEXIST
@@ -155,7 +155,7 @@
 # define BOOST_COPY_DIRECTORY(F,T) (::CreateDirectoryExW( F, T, 0 ) != 0)
 # define BOOST_COPY_FILE(F,T,FailIfExistsBool) (::CopyFileW(F, T, FailIfExistsBool) != 0)
 # define BOOST_MOVE_FILE(F,T) (::MoveFileW( F, T ) != 0)
-# define BOOST_SET_FILE_SIZE(P,SZ) (file_size_file_api( P, SZ ) != 0)
+# define BOOST_RESIZE_FILE(P,SZ) (resize_file_api( P, SZ ) != 0)
 # define BOOST_READ_SYMLINK(P,T)
 
 # define BOOST_ERROR_ALREADY_EXISTS ERROR_ALREADY_EXISTS
@@ -394,7 +394,7 @@
       ::GetFullPathNameW( src.c_str(), static_cast<DWORD>(len), buf, p ));
   }
 
- BOOL file_size_file_api( const wchar_t * p, boost::uintmax_t size )
+ BOOL resize_file_api( const wchar_t * p, boost::uintmax_t size )
   {
     HANDLE handle = CreateFileW( p, GENERIC_WRITE, 0, 0, OPEN_EXISTING,
                                 FILE_ATTRIBUTE_NORMAL, 0 );
@@ -935,12 +935,6 @@
   }
 
   BOOST_FILESYSTEM_DECL
- void file_size( const path & p, uintmax_t size, system::error_code & ec )
- {
- error( !BOOST_SET_FILE_SIZE( p.c_str(), size ), p, ec, "boost::filesystem::file_size");
- }
-
- BOOST_FILESYSTEM_DECL
   boost::uintmax_t hard_link_count( const path & p, system::error_code & ec )
   {
 # ifdef BOOST_WINDOWS_API
@@ -1154,6 +1148,12 @@
   }
 
   BOOST_FILESYSTEM_DECL
+ void resize_file( const path & p, uintmax_t size, system::error_code & ec )
+ {
+ error(!BOOST_RESIZE_FILE( p.c_str(), size ), p, ec, "boost::filesystem::resize_file");
+ }
+
+ BOOST_FILESYSTEM_DECL
   space_info space( const path & p, error_code & ec )
   {
 # ifdef BOOST_WINDOWS_API

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 2009-10-17 10:51:36 EDT (Sat, 17 Oct 2009)
@@ -731,28 +731,28 @@
     BOOST_TEST( fs::is_directory( p ) );
   }
 
- // file_size_tests ----------------------------------------------------//
+ // resize_file_tests ----------------------------------------------------//
 
- void file_size_tests()
+ void resize_file_tests()
   {
- std::cout << "file_size_tests..." << std::endl;
+ std::cout << "resize_file_tests..." << std::endl;
 
- const std::string f ("file_size_test.txt");
+ const std::string f ("resize_file_test.txt");
 
     fs::remove( f );
     create_file( f, "1234567890" );
 
     BOOST_TEST( fs::exists(f) );
     BOOST_TEST_EQ( fs::file_size(f), 10 );
- fs::file_size( f, 5 );
+ fs::resize_file( f, 5 );
     BOOST_TEST( fs::exists(f) );
     BOOST_TEST_EQ( fs::file_size(f), 5 );
- fs::file_size( f, 15 );
+ fs::resize_file( f, 15 );
     BOOST_TEST( fs::exists(f) );
     BOOST_TEST_EQ( fs::file_size(f), 15 );
 
     error_code ec;
- fs::file_size( "no such file", 15, ec );
+ fs::resize_file( "no such file", 15, ec );
     BOOST_TEST( ec );
   }
 
@@ -974,7 +974,7 @@
   
   create_hard_link_tests();
   create_symlink_tests();
- file_size_tests();
+ resize_file_tests();
 
   // copy_file() tests
   std::cout << "begin copy_file test..." << std::endl;


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