[gparted] Remove 512 byte based units and rename _FACTOR to BYTE
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Remove 512 byte based units and rename _FACTOR to BYTE
- Date: Mon, 26 Apr 2010 19:41:47 +0000 (UTC)
commit cb08e8c7ddf206a15de2d182c22a00b714fe66ff
Author: Curtis Gedak <gedakc gmail com>
Date: Mon Apr 26 13:40:38 2010 -0600
Remove 512 byte based units and rename _FACTOR to BYTE
With the removal of the 512 byte constants, such as MEBIBYTE, it
was possible to rename the _FACTOR constants back to BYTE
constants. The _FACTOR constants, such as MEBI_FACTOR, were a
temporary measure to help in the transition to support devices
with sector sizes > 512 bytes.
include/Utils.h | 14 ++++----------
src/Dialog_Base_Partition.cc | 8 ++++----
src/Dialog_Partition_Copy.cc | 8 ++++----
src/Dialog_Partition_New.cc | 20 ++++++++++----------
src/Dialog_Partition_Resize_Move.cc | 8 ++++----
src/GParted_Core.cc | 12 ++++++------
src/Operation.cc | 6 +++---
src/Utils.cc | 16 ++++++++--------
src/fat16.cc | 4 ++--
src/fat32.cc | 2 +-
src/hfs.cc | 4 ++--
src/jfs.cc | 4 ++--
src/reiserfs.cc | 2 +-
src/xfs.cc | 4 ++--
14 files changed, 53 insertions(+), 59 deletions(-)
---
diff --git a/include/Utils.h b/include/Utils.h
index 94b65c7..4f8bb29 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -40,17 +40,11 @@ namespace GParted
typedef long long Sector;
typedef long long Byte_Value;
-//sizeunits defined in sectors of 512 bytes..
-#define KIBIBYTE 2
-#define MEBIBYTE 2048
-#define GIBIBYTE 2097152
-#define TEBIBYTE 2147483648U
-
//Size units defined in bytes
-const Byte_Value KIBI_FACTOR=1024;
-const Byte_Value MEBI_FACTOR=(KIBI_FACTOR * KIBI_FACTOR);
-const Byte_Value GIBI_FACTOR=(MEBI_FACTOR * KIBI_FACTOR);
-const Byte_Value TEBI_FACTOR=(GIBI_FACTOR * KIBI_FACTOR);
+const Byte_Value KIBIBYTE=1024;
+const Byte_Value MEBIBYTE=(KIBIBYTE * KIBIBYTE);
+const Byte_Value GIBIBYTE=(MEBIBYTE * KIBIBYTE);
+const Byte_Value TEBIBYTE=(GIBIBYTE * KIBIBYTE);
enum FILESYSTEM
{
diff --git a/src/Dialog_Base_Partition.cc b/src/Dialog_Base_Partition.cc
index 4fd8888..9acdd60 100644
--- a/src/Dialog_Base_Partition.cc
+++ b/src/Dialog_Base_Partition.cc
@@ -127,11 +127,11 @@ Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
//FIXME: Partition size is limited to just less than 1024 TeraBytes due
// to the maximum value of signed 4 byte integer.
if ( ORIG_BEFORE != spinbutton_before .get_value_as_int() )
- selected_partition .sector_start = START + Sector(spinbutton_before .get_value_as_int()) * (MEBI_FACTOR / sector_size) ;
+ selected_partition .sector_start = START + Sector(spinbutton_before .get_value_as_int()) * (MEBIBYTE / sector_size) ;
if ( ORIG_AFTER != spinbutton_after .get_value_as_int() )
selected_partition .sector_end =
- selected_partition .sector_start + Sector(spinbutton_size .get_value_as_int()) * (MEBI_FACTOR / sector_size) ;
+ selected_partition .sector_start + Sector(spinbutton_size .get_value_as_int()) * (MEBIBYTE / sector_size) ;
//due to loss of precision during calcs from Sector -> MiB and back, it is possible
//the new partition thinks it's bigger then it can be. Here we solve this.
@@ -141,9 +141,9 @@ Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
selected_partition .sector_end = START + total_length -1 ;
//grow a bit into small freespace ( < 1MiB )
- if ( (selected_partition .sector_start - START) < (MEBI_FACTOR / sector_size) )
+ if ( (selected_partition .sector_start - START) < (MEBIBYTE / sector_size) )
selected_partition .sector_start = START ;
- if ( ( START + total_length -1 - selected_partition .sector_end ) < (MEBI_FACTOR / sector_size) )
+ if ( ( START + total_length -1 - selected_partition .sector_end ) < (MEBIBYTE / sector_size) )
selected_partition .sector_end = START + total_length -1 ;
//set new value of unused..
diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc
index 74e1974..442c3c0 100644
--- a/src/Dialog_Partition_Copy.cc
+++ b/src/Dialog_Partition_Copy.cc
@@ -103,7 +103,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
copied_partition .sectors_used, copied_partition .sector_size, UNIT_MIB ) / (TOTAL_MB/500.00) ) ) ;
if ( fs .grow )
- fs .MAX = ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBI_FACTOR) ) ? (TOTAL_MB * MEBI_FACTOR) : fs .MAX - (BUF * selected_partition .sector_size) ;
+ fs .MAX = ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBIBYTE) ) ? (TOTAL_MB * MEBIBYTE) : fs .MAX - (BUF * selected_partition .sector_size) ;
else
fs .MAX = copied_partition .get_length() * copied_partition .sector_size ;
@@ -111,7 +111,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
if ( fs .filesystem == GParted::FS_XFS ) //bit hackisch, but most effective, since it's a unique situation
fs .MIN = ( copied_partition .sectors_used + (BUF * 2) ) * copied_partition .sector_size;
else
- fs .MIN = COPIED_LENGTH_MB * MEBI_FACTOR ;
+ fs .MIN = COPIED_LENGTH_MB * MEBIBYTE ;
GRIP = true ;
//set values of spinbutton_before
@@ -129,8 +129,8 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
spinbutton_after .set_value( TOTAL_MB - COPIED_LENGTH_MB ) ;
GRIP = false ;
- frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
- Utils::round( fs .MAX / (MB_PER_PIXEL * MEBI_FACTOR) ) ) ;
+ frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
+ Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
//set contents of label_minmax
Set_MinMax_Text(
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 1bddc6b..94fa377 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -155,7 +155,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
spinbutton_before .set_value( 0 ) ;
//euhrm, this wil only happen when there's a very small free space (usually the effect of a bad partitionmanager)
- if ( TOTAL_MB * (MEBI_FACTOR / this ->selected_partition .sector_size) < this ->cylinder_size )
+ if ( TOTAL_MB * (MEBIBYTE / this ->selected_partition .sector_size) < this ->cylinder_size )
frame_resizer_base ->set_sensitive( false ) ;
this ->show_all_children() ;
@@ -178,8 +178,8 @@ Partition Dialog_Partition_New::Get_New_Partition( Byte_Value sector_size )
//FIXME: Partition size is limited to just less than 1024 TeraBytes due
// to the maximum value of signed 4 byte integer.
- new_start = START + (Sector(spinbutton_before .get_value_as_int()) * (MEBI_FACTOR / sector_size)) ;
- new_end = new_start + (Sector(spinbutton_size .get_value_as_int()) * (MEBI_FACTOR / sector_size)) - 1 ;
+ new_start = START + (Sector(spinbutton_before .get_value_as_int()) * (MEBIBYTE / sector_size)) ;
+ new_end = new_start + (Sector(spinbutton_size .get_value_as_int()) * (MEBIBYTE / sector_size)) - 1 ;
/* due to loss of precision during calcs from Sector -> MiB and back, it is possible the new
* partition thinks it's bigger then it can be. Here we try to solve this.*/
@@ -201,9 +201,9 @@ Partition Dialog_Partition_New::Get_New_Partition( Byte_Value sector_size )
part_temp .label = Utils::trim( entry .get_text() );
//grow new partition a bit if freespaces are < 1 MiB
- if ( (part_temp.sector_start - selected_partition.sector_start) < (MEBI_FACTOR / sector_size) )
+ if ( (part_temp.sector_start - selected_partition.sector_start) < (MEBIBYTE / sector_size) )
part_temp.sector_start = selected_partition.sector_start ;
- if ( (selected_partition.sector_end - part_temp.sector_end) < (MEBI_FACTOR / sector_size) )
+ if ( (selected_partition.sector_end - part_temp.sector_end) < (MEBIBYTE / sector_size) )
part_temp.sector_end = selected_partition.sector_end ;
//if new is extended...
@@ -256,16 +256,16 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
if ( (fs .MIN / selected_partition .sector_size) < cylinder_size )
fs .MIN = cylinder_size * selected_partition .sector_size ;
}
- else if ( fs .MIN < MEBI_FACTOR )
- fs .MIN = MEBI_FACTOR ;
+ else if ( fs .MIN < MEBIBYTE )
+ fs .MIN = MEBIBYTE ;
if ( selected_partition .get_length() < (fs .MIN / selected_partition .sector_size) )
fs .MIN = selected_partition .get_length() * selected_partition .sector_size ;
- fs .MAX = ( fs .MAX && ( fs .MAX < (TOTAL_MB * MEBI_FACTOR) ) ) ? fs .MAX : (TOTAL_MB * MEBI_FACTOR) ;
+ fs .MAX = ( fs .MAX && ( fs .MAX < (TOTAL_MB * MEBIBYTE) ) ) ? fs .MAX : (TOTAL_MB * MEBIBYTE) ;
- frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
- Utils::round( fs .MAX / (MB_PER_PIXEL * MEBI_FACTOR) ) ) ;
+ frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
+ Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
//set new spinbutton ranges
spinbutton_before .set_range(
diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc
index 7b23321..12e2da4 100644
--- a/src/Dialog_Partition_Resize_Move.cc
+++ b/src/Dialog_Partition_Resize_Move.cc
@@ -134,8 +134,8 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
//set MAX
if ( fs .grow )
{
- if ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBI_FACTOR) )
- fs .MAX = TOTAL_MB * MEBI_FACTOR ;
+ if ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBIBYTE) )
+ fs .MAX = TOTAL_MB * MEBIBYTE ;
else
fs .MAX -= (BUF/2 * selected_partition .sector_size) ;
}
@@ -168,8 +168,8 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
spinbutton_after .set_value(
Utils::round( Utils::sector_to_unit( next, selected_partition .sector_size, UNIT_MIB ) ) ) ;
- frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
- Utils::round( fs .MAX / (MB_PER_PIXEL * MEBI_FACTOR) ) ) ;
+ frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
+ Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
//set contents of label_minmax
Set_MinMax_Text(
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index f437465..0d86285 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -305,8 +305,8 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
temp_device .cylsize = temp_device .heads * temp_device .sectors ;
//make sure cylsize is at least 1 MiB
- if ( temp_device .cylsize < (MEBI_FACTOR / temp_device .sector_size) )
- temp_device .cylsize = (MEBI_FACTOR / temp_device .sector_size) ;
+ if ( temp_device .cylsize < (MEBIBYTE / temp_device .sector_size) )
+ temp_device .cylsize = (MEBIBYTE / temp_device .sector_size) ;
//normal harddisk
if ( lp_disk )
@@ -1101,7 +1101,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
}
//start <---> first partition start
- if ( (partitions .front() .sector_start - start) >= (MEBI_FACTOR / sector_size) )
+ if ( (partitions .front() .sector_start - start) >= (MEBIBYTE / sector_size) )
{
partition_temp .sector_start = start ;
partition_temp .sector_end = partitions .front() .sector_start -1 ;
@@ -1111,7 +1111,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
//look for gaps in between
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
- if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= (MEBI_FACTOR / sector_size) )
+ if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= (MEBIBYTE / sector_size) )
{
partition_temp .sector_start = partitions[ t ] .sector_end +1 ;
partition_temp .sector_end = partitions[ t +1 ] .sector_start -1 ;
@@ -1120,7 +1120,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
}
//last partition end <---> end
- if ( (end - partitions .back() .sector_end ) >= (MEBI_FACTOR / sector_size) )
+ if ( (end - partitions .back() .sector_end ) >= (MEBIBYTE / sector_size) )
{
partition_temp .sector_start = partitions .back() .sector_end +1 ;
partition_temp .sector_end = end ;
@@ -2142,7 +2142,7 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
operationdetail .add_child( OperationDetail( _("finding optimal block size"), STATUS_NONE ) ) ;
- Byte_Value benchmark_blocksize = readonly ? (2 * MEBI_FACTOR) : (1 * MEBI_FACTOR), N = (16 * MEBI_FACTOR) ;
+ Byte_Value benchmark_blocksize = readonly ? (2 * MEBIBYTE) : (1 * MEBIBYTE), N = (16 * MEBIBYTE) ;
Byte_Value optimal_blocksize = benchmark_blocksize ;
Sector offset_read = src_start ;
Sector offset_write = dst_start ;
diff --git a/src/Operation.cc b/src/Operation.cc
index 9efc778..ca04915 100644
--- a/src/Operation.cc
+++ b/src/Operation.cc
@@ -60,7 +60,7 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
}
//start <---> first partition start
- if ( (partitions .front() .sector_start - start) >= (MEBI_FACTOR / sector_size) )
+ if ( (partitions .front() .sector_start - start) >= (MEBIBYTE / sector_size) )
{
UNALLOCATED .sector_start = start ;
UNALLOCATED .sector_end = partitions .front() .sector_start -1 ;
@@ -70,7 +70,7 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
//look for gaps in between
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
- if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= (MEBI_FACTOR / sector_size) )
+ if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= (MEBIBYTE / sector_size) )
{
UNALLOCATED .sector_start = partitions[ t ] .sector_end +1 ;
UNALLOCATED .sector_end = partitions[ t +1 ] .sector_start -1 ;
@@ -79,7 +79,7 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
}
//last partition end <---> end
- if ( (end - partitions .back() .sector_end ) >= (MEBI_FACTOR / sector_size) )
+ if ( (end - partitions .back() .sector_end ) >= (MEBIBYTE / sector_size) )
{
UNALLOCATED .sector_start = partitions .back() .sector_end +1 ;
UNALLOCATED .sector_end = end ;
diff --git a/src/Utils.cc b/src/Utils.cc
index 24cc8c8..504f284 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -172,22 +172,22 @@ Glib::ustring Utils::format_size( Sector sectors, Byte_Value sector_size )
std::stringstream ss ;
ss << std::setiosflags( std::ios::fixed ) << std::setprecision( 2 ) ;
- if ( (sectors * sector_size) < KIBI_FACTOR )
+ if ( (sectors * sector_size) < KIBIBYTE )
{
ss << sector_to_unit( sectors, sector_size, UNIT_BYTE ) ;
return String::ucompose( _("%1 B"), ss .str() ) ;
}
- else if ( (sectors * sector_size) < MEBI_FACTOR )
+ else if ( (sectors * sector_size) < MEBIBYTE )
{
ss << sector_to_unit( sectors, sector_size, UNIT_KIB ) ;
return String::ucompose( _("%1 KiB"), ss .str() ) ;
}
- else if ( (sectors * sector_size) < GIBI_FACTOR )
+ else if ( (sectors * sector_size) < GIBIBYTE )
{
ss << sector_to_unit( sectors, sector_size, UNIT_MIB ) ;
return String::ucompose( _("%1 MiB"), ss .str() ) ;
}
- else if ( (sectors * sector_size) < TEBI_FACTOR )
+ else if ( (sectors * sector_size) < TEBIBYTE )
{
ss << sector_to_unit( sectors, sector_size, UNIT_GIB ) ;
return String::ucompose( _("%1 GiB"), ss .str() ) ;
@@ -230,13 +230,13 @@ double Utils::sector_to_unit( Sector sectors, Byte_Value sector_size, SIZE_UNIT
return sectors * sector_size ;
case UNIT_KIB :
- return sectors / ( static_cast<double>( KIBI_FACTOR ) / sector_size );
+ return sectors / ( static_cast<double>( KIBIBYTE ) / sector_size );
case UNIT_MIB :
- return sectors / ( static_cast<double>( MEBI_FACTOR ) / sector_size );
+ return sectors / ( static_cast<double>( MEBIBYTE ) / sector_size );
case UNIT_GIB :
- return sectors / ( static_cast<double>( GIBI_FACTOR ) / sector_size );
+ return sectors / ( static_cast<double>( GIBIBYTE ) / sector_size );
case UNIT_TIB :
- return sectors / ( static_cast<double>( TEBI_FACTOR ) / sector_size );
+ return sectors / ( static_cast<double>( TEBIBYTE ) / sector_size );
default:
return sectors ;
diff --git a/src/fat16.cc b/src/fat16.cc
index 4e59b44..95bb5d8 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -56,8 +56,8 @@ FS fat16::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
- fs .MIN = 16 * MEBI_FACTOR ;
- fs .MAX = (4096 - 1) * MEBI_FACTOR ; //Maximum seems to be just less than 4096 MiB
+ fs .MIN = 16 * MEBIBYTE ;
+ fs .MAX = (4096 - 1) * MEBIBYTE ; //Maximum seems to be just less than 4096 MiB
return fs ;
}
diff --git a/src/fat32.cc b/src/fat32.cc
index cbbd11d..9c99018 100644
--- a/src/fat32.cc
+++ b/src/fat32.cc
@@ -56,7 +56,7 @@ FS fat32::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
- fs .MIN = 32 * MEBI_FACTOR ; //smaller fs'es will cause windows scandisk to fail..
+ fs .MIN = 32 * MEBIBYTE ; //smaller fs'es will cause windows scandisk to fail..
return fs ;
}
diff --git a/src/hfs.cc b/src/hfs.cc
index 1ca6e4a..ba37066 100644
--- a/src/hfs.cc
+++ b/src/hfs.cc
@@ -1,5 +1,5 @@
/* Copyright (C) 2004 Bart
- * Copyright (C) 2008 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010 Curtis Gedak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -43,7 +43,7 @@ FS hfs::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .move = GParted::FS::GPARTED ;
- fs .MAX = 2048 * MEBI_FACTOR ;
+ fs .MAX = 2048 * MEBIBYTE ;
return fs ;
}
diff --git a/src/jfs.cc b/src/jfs.cc
index d430e83..48e41ca 100644
--- a/src/jfs.cc
+++ b/src/jfs.cc
@@ -1,5 +1,5 @@
/* Copyright (C) 2004 Bart
- * Copyright (C) 2008 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010 Curtis Gedak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -71,7 +71,7 @@ FS jfs::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
}
- fs .MIN = 16 * MEBI_FACTOR ;
+ fs .MIN = 16 * MEBIBYTE ;
return fs ;
}
diff --git a/src/reiserfs.cc b/src/reiserfs.cc
index b36b39e..854c7a2 100644
--- a/src/reiserfs.cc
+++ b/src/reiserfs.cc
@@ -58,7 +58,7 @@ FS reiserfs::get_filesystem_support()
}
//Actual minimum is at least 18 blocks larger than 32 MiB for the journal offset
- fs .MIN = 34 * MEBI_FACTOR ;
+ fs .MIN = 34 * MEBIBYTE ;
return fs ;
}
diff --git a/src/xfs.cc b/src/xfs.cc
index f03d0bc..c6f76d8 100644
--- a/src/xfs.cc
+++ b/src/xfs.cc
@@ -1,5 +1,5 @@
/* Copyright (C) 2004 Bart
- * Copyright (C) 2008 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010 Curtis Gedak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -72,7 +72,7 @@ FS xfs::get_filesystem_support()
if ( fs .check )
fs .move = GParted::FS::GPARTED ;
- fs .MIN = 32 * MEBI_FACTOR ;//official minsize = 16MB, but the smallest xfs_repair can handle is 32MB...
+ fs .MIN = 32 * MEBIBYTE ;//official minsize = 16MB, but the smallest xfs_repair can handle is 32MB...
return fs ;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]