[gparted] Remove unused read-only functionality from internal block copy



commit aed1fb58cf45ff26439c0906c3609ec888d251d2
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Thu May 23 20:51:47 2013 +0100

    Remove unused read-only functionality from internal block copy
    
    The read-only functionality is unused and the readonly parameter is
    always false in copy_filesystem() and copy_blocks() methods.  This has
    been the case since the copy simulation was dropped by commit:
    
        b9b4b2e55d1dadd5a5c0fef552dbbd2499561182
        Remove simulation pass ( read test ) on move

 include/Copy_Blocks.h  |    2 --
 include/GParted_Core.h |    2 --
 src/Copy_Blocks.cc     |   38 +++++++++++---------------------------
 src/GParted_Core.cc    |   34 ++++++++++------------------------
 4 files changed, 21 insertions(+), 55 deletions(-)
---
diff --git a/include/Copy_Blocks.h b/include/Copy_Blocks.h
index fcf79cd..1da3305 100644
--- a/include/Copy_Blocks.h
+++ b/include/Copy_Blocks.h
@@ -29,7 +29,6 @@ class copy_blocks {
        Byte_Value length;
        Byte_Value blocksize;
        OperationDetail &operationdetail;
-       bool readonly;
        Byte_Value & total_done;
        char *buf;
        Byte_Value done;
@@ -53,7 +52,6 @@ public:
                     Byte_Value in_length,
                     Byte_Value in_blocksize,
                     OperationDetail & in_operationdetail,
-                    bool in_readonly,
                     Byte_Value & in_total_done,
                     bool cancel_safe );
        bool copy();
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 52f703c..fc1ce9c 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -143,7 +143,6 @@ private:
        bool copy_filesystem( const Partition & partition_src,
                              const Partition & partition_dst,
                              OperationDetail & operationdetail,
-                             bool readonly,
                              bool cancel_safe );
        bool copy_filesystem( const Partition & partition_src,
                              const Partition & partition_dst,
@@ -158,7 +157,6 @@ private:
                              Byte_Value dst_sector_size,
                              Byte_Value src_length,
                              OperationDetail & operationdetail,
-                             bool readonly,
                              Byte_Value & total_done,
                              bool cancel_safe ) ;
        void rollback_transaction( const Partition & partition_src,
diff --git a/src/Copy_Blocks.cc b/src/Copy_Blocks.cc
index ca266c4..6a9b03e 100644
--- a/src/Copy_Blocks.cc
+++ b/src/Copy_Blocks.cc
@@ -36,7 +36,6 @@ copy_blocks::copy_blocks( const Glib::ustring & in_src_device,
                          Byte_Value in_length,
                          Byte_Value in_blocksize,
                          OperationDetail & in_operationdetail,
-                         bool in_readonly,
                          Byte_Value & in_total_done,
                          bool in_cancel_safe) :
        src_device( in_src_device ),
@@ -44,7 +43,6 @@ copy_blocks::copy_blocks( const Glib::ustring & in_src_device,
        length ( in_length ),
        blocksize ( in_blocksize ),
        operationdetail ( in_operationdetail ),
-       readonly ( in_readonly ),
        total_done ( in_total_done ),
        offset_src ( src_start ),
        offset_dst ( dst_start ),
@@ -66,23 +64,17 @@ bool copy_blocks::set_progress_info()
        std::time_t time_remaining = Utils::round( (length - done) / ( done / timer_total.elapsed() ) );
 
        operationdetail.progress_text =
-               String::ucompose( readonly ?
-                               /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB read (00:01:59 remaining) 
*/
-                               _("%1 of %2 read (%3 remaining)") :
-                               /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB copied (00:01:59 
remaining) */
-                               _("%1 of %2 copied (%3 remaining)"),
+               String::ucompose( /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB copied (00:01:59 
remaining) */
+                                 _("%1 of %2 copied (%3 remaining)"),
                                  Utils::format_size( done, 1 ),
                                  Utils::format_size( length,1 ),
                                  Utils::format_time( time_remaining ) );
 
        operationdetail.set_description(
-               String::ucompose( readonly ?
-                               /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB read */
-                               _("%1 of %2 read") :
-                               /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB copied */
+               String::ucompose( /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB copied */
                                _("%1 of %2 copied"),
                                Utils::format_size( done, 1 ), Utils::format_size( length, 1 ) ),
-                               FONT_ITALIC );
+               FONT_ITALIC );
        return false;
 }
 
@@ -164,16 +156,11 @@ bool copy_blocks::copy()
        if ( blocksize > length )
                blocksize = length;
 
-       if ( readonly )
-               operationdetail.add_child( OperationDetail(
-                               /*TO TRANSLATORS: looks like  read 16.00 MiB using a block size of 1.00 MiB */
-                               String::ucompose( _("read %1 using a block size of %2"), Utils::format_size( 
length, 1 ),
-                                       Utils::format_size( blocksize, 1 ) ) ) );
-       else
-               operationdetail.add_child( OperationDetail(
-                               /*TO TRANSLATORS: looks like  copy 16.00 MiB using a block size of 1.00 MiB */
-                               String::ucompose( _("copy %1 using a block size of %2"), Utils::format_size( 
length, 1 ),
-                                       Utils::format_size( blocksize, 1 ) ) ) );
+       operationdetail.add_child( OperationDetail(
+                       /*TO TRANSLATORS: looks like  copy 16.00 MiB using a block size of 1.00 MiB */
+                       String::ucompose( _("copy %1 using a block size of %2"),
+                                         Utils::format_size( length, 1 ),
+                                         Utils::format_size( blocksize, 1 ) ) ) );
 
        done = length % blocksize;
 
@@ -194,10 +181,7 @@ bool copy_blocks::copy()
 
                        //final description
                        operationdetail.get_last_child().get_last_child().set_description(
-                               String::ucompose( readonly ?
-                                                 /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB read */
-                                                 _("%1 of %2 read") :
-                                                 /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB copied 
*/
+                               String::ucompose( /*TO TRANSLATORS: looks like  1.00 MiB of 16.00 MiB copied 
*/
                                                  _("%1 of %2 copied"),
                                                  Utils::format_size( llabs( done ), 1 ),
                                                  Utils::format_size( length, 1 ) ),
@@ -245,7 +229,7 @@ void copy_blocks::copy_block()
        {
                if ( ped_device_read( lp_device_src, buf, offset_src, num_blocks_src ) )
                {
-                       if ( readonly || ped_device_write( lp_device_dst, buf, offset_dst, num_blocks_dst ) )
+                       if ( ped_device_write( lp_device_dst, buf, offset_dst, num_blocks_dst ) )
                                success = true;
                        else {
                                error_message = String::ucompose( _("Error while writing block at sector 
%1"), offset_dst );
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 0d1aed3..8707066 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2613,7 +2613,6 @@ bool GParted_Core::copy( const Partition & partition_src,
                                                succes = copy_filesystem( partition_src,
                                                                          partition_dst,
                                                                          operationdetail .get_last_child(),
-                                                                         false,
                                                                          true ) ;
                                                break ;
 
@@ -2657,7 +2656,6 @@ bool GParted_Core::copy( const Partition & partition_src,
 bool GParted_Core::copy_filesystem( const Partition & partition_src,
                                    const Partition & partition_dst,
                                    OperationDetail & operationdetail,
-                                   bool readonly,
                                    bool cancel_safe )
 {
        Sector dummy ;
@@ -2669,7 +2667,6 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
                                partition_dst .sector_size,
                                partition_src .get_byte_length(),
                                operationdetail,
-                               readonly,
                                dummy,
                                cancel_safe ) ;
 }
@@ -2688,7 +2685,6 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
                                partition_dst .sector_size,
                                partition_src .get_byte_length(),
                                operationdetail,
-                               false,
                                total_done,
                                cancel_safe ) ;
 }
@@ -2701,23 +2697,19 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
                                    Byte_Value dst_sector_size,
                                    Byte_Value src_length,
                                    OperationDetail & operationdetail,
-                                   bool readonly,
                                    Byte_Value & total_done,
                                    bool cancel_safe )
 {
        operationdetail .add_child( OperationDetail( _("using internal algorithm"), STATUS_NONE ) ) ;
-       operationdetail .add_child( OperationDetail( 
-               String::ucompose( readonly ?
-                               /*TO TRANSLATORS: looks like  read 1.00 MiB */
-                               _("read %1") :
-                               /*TO TRANSLATORS: looks like  copy 1.00 MiB */
-                               _("copy %1"),
-                               Utils::format_size( src_length, 1 ) ),
-                               STATUS_NONE ) ) ;
+       operationdetail .add_child( OperationDetail(
+               String::ucompose( /*TO TRANSLATORS: looks like  copy 1.00 MiB */
+                                 _("copy %1"), Utils::format_size( src_length, 1 ) ),
+               STATUS_NONE ) ) ;
 
        operationdetail .add_child( OperationDetail( _("finding optimal block size"), STATUS_NONE ) ) ;
 
-       Byte_Value benchmark_blocksize = readonly ? (2 * MEBIBYTE) : (1 * MEBIBYTE), N = (16 * MEBIBYTE) ;
+       Byte_Value benchmark_blocksize = (1 * MEBIBYTE) ;
+       Byte_Value N = (16 * MEBIBYTE) ;
        Byte_Value optimal_blocksize = benchmark_blocksize ;
        Sector offset_read = src_start ;
        Sector offset_write = dst_start ;
@@ -2750,7 +2742,6 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
                                      N,
                                      benchmark_blocksize,
                                      operationdetail .get_last_child(),
-                                     readonly,
                                      total_done,
                                      cancel_safe ).copy();
                timer.stop() ;
@@ -2786,18 +2777,13 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
                                      src_length - llabs( done ),
                                      optimal_blocksize,
                                      operationdetail,
-                                     readonly,
                                      total_done,
                                      cancel_safe ).copy();
 
        operationdetail .add_child( OperationDetail( 
-               String::ucompose( readonly ?
-                               /*TO TRANSLATORS: looks like  1.00 MiB (1048576 B) read */
-                               _("%1 (%2 B) read") :
-                               /*TO TRANSLATORS: looks like  1.00 MiB (1048576 B) copied */
-                               _("%1 (%2 B) copied"),
-                               Utils::format_size( total_done, 1 ), total_done ),
-                               STATUS_NONE ) ) ;
+               String::ucompose( /*TO TRANSLATORS: looks like  1.00 MiB (1048576 B) copied */
+                                 _("%1 (%2 B) copied"), Utils::format_size( total_done, 1 ), total_done ),
+               STATUS_NONE ) ) ;
        return succes ;
 }
 
@@ -2832,7 +2818,7 @@ void GParted_Core::rollback_transaction( const Partition & partition_src,
                operationdetail.add_child( OperationDetail( _("roll back last transaction") ) );
 
                //and copy it back (NOTE the reversed dst and src)
-               bool succes = copy_filesystem( temp_dst, temp_src, operationdetail .get_last_child(), false, 
false ) ;
+               bool succes = copy_filesystem( temp_dst, temp_src, operationdetail .get_last_child(), false ) 
;
 
                operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]