changed the way devices and partitions store their devicepaths. Instead of
* changed the way devices and partitions store their devicepaths. Instead of holding a 'realpath' and a symbolic path we store paths in a list. This allows for improved detection of mountpoins, free space, etc.. Also fixed a nasty bug which showed up when you copy a partition from one device to another. (thanks to mario for the report)
This commit is contained in:
parent
7fdcec2b1d
commit
6d8b169e73
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2006-03-14 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* changed the way devices and partitions store their devicepaths.
|
||||
Instead of holding a 'realpath' and a symbolic path we store paths
|
||||
in a list. This allows for improved detection of mountpoins, free
|
||||
space, etc..
|
||||
|
||||
Also fixed a nasty bug which showed up when you copy a partition
|
||||
from one device to another. (thanks to mario for the report)
|
||||
|
||||
2006-03-09 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Makefile.am,
|
||||
|
|
|
@ -30,8 +30,12 @@ public:
|
|||
Device() ;
|
||||
~Device() ;
|
||||
|
||||
void Reset() ;
|
||||
void add_path( const Glib::ustring & path, bool clear_paths = false ) ;
|
||||
void add_paths( const std::vector<Glib::ustring> & paths, bool clear_paths = false ) ;
|
||||
Glib::ustring get_path() ;
|
||||
std::vector<Glib::ustring> get_paths() ;
|
||||
|
||||
void Reset() ;
|
||||
std::vector<Partition> partitions ;
|
||||
Sector length;
|
||||
long heads ;
|
||||
|
@ -39,15 +43,17 @@ public:
|
|||
long cylinders ;
|
||||
Sector cylsize ;
|
||||
Glib::ustring model;
|
||||
Glib::ustring path;
|
||||
Glib::ustring realpath;
|
||||
Glib::ustring disktype;
|
||||
int max_prims ;
|
||||
int highest_busy ;
|
||||
bool readonly ;
|
||||
|
||||
private:
|
||||
void sort_paths_and_remove_duplicates() ;
|
||||
|
||||
static bool compare_paths( const Glib::ustring & A, const Glib::ustring & B ) ;
|
||||
|
||||
std::vector<Glib::ustring> paths ;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -77,14 +77,13 @@ private:
|
|||
std::map< Glib::ustring, std::vector<Glib::ustring> > & map ) ;
|
||||
void init_maps() ;
|
||||
void set_mountpoints( std::vector<Partition> & partitions ) ;
|
||||
void set_short_paths( std::vector<Partition> & partitions ) ;
|
||||
void set_used_sectors( std::vector<Partition> & partitions ) ;
|
||||
void insert_unallocated( const Glib::ustring & device_path,
|
||||
std::vector<Partition> & partitions,
|
||||
Sector start,
|
||||
Sector end,
|
||||
bool inside_extended ) ;
|
||||
Glib::ustring get_short_path( const Glib::ustring & real_path ) ;
|
||||
std::vector<Glib::ustring> get_alternate_paths( const Glib::ustring & path ) ;
|
||||
void LP_Set_Used_Sectors( Partition & partition );
|
||||
void set_flags( Partition & partition ) ;
|
||||
int create_empty_partition( Partition & new_partition,
|
||||
|
@ -122,7 +121,7 @@ private:
|
|||
|
||||
std::map< Glib::ustring, std::vector<Glib::ustring> > mount_info ;
|
||||
std::map< Glib::ustring, std::vector<Glib::ustring> > fstab_info ;
|
||||
std::map< Glib::ustring, Glib::ustring > short_paths ;
|
||||
std::map< Glib::ustring, Glib::ustring > alternate_paths ;
|
||||
std::map< Glib::ustring, Glib::ustring >::iterator iter ;
|
||||
std::map< Glib::ustring, std::vector<Glib::ustring> >::iterator iter_mp ;
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ class Partition
|
|||
{
|
||||
public:
|
||||
Partition() ;
|
||||
Partition( const Glib::ustring & path ) ;
|
||||
~Partition() ;
|
||||
|
||||
void Reset() ;
|
||||
|
@ -64,18 +65,23 @@ public:
|
|||
|
||||
void Set_Unused( Sector sectors_unused ) ;
|
||||
|
||||
void Set_Unallocated( const Glib::ustring & device_path, Sector sector_start, Sector sector_end, bool inside_extended );
|
||||
void Set_Unallocated( const Glib::ustring & device_path,
|
||||
Sector sector_start,
|
||||
Sector sector_end,
|
||||
bool inside_extended );
|
||||
|
||||
//update partition number (used when a logical partition is deleted)
|
||||
void Update_Number( int new_number );
|
||||
|
||||
void add_path( const Glib::ustring & path, bool clear_paths = false ) ;
|
||||
void add_paths( const std::vector<Glib::ustring> & paths, bool clear_paths = false ) ;
|
||||
Sector get_length() const ;
|
||||
Glib::ustring get_path() const ;
|
||||
std::vector<Glib::ustring> get_paths() const ;
|
||||
|
||||
bool operator==( const Partition & partition ) const ;
|
||||
|
||||
//some public members
|
||||
Glib::ustring partition;//the symbolic path (e.g. /dev/hda1 )
|
||||
Glib::ustring realpath ;
|
||||
Glib::ustring device_path ;
|
||||
int partition_number;
|
||||
PartitionType type;// UNALLOCATED, PRIMARY, LOGICAL, etc...
|
||||
|
@ -90,15 +96,19 @@ public:
|
|||
bool busy;
|
||||
Glib::ustring error;
|
||||
std::vector<Glib::ustring> flags ;
|
||||
std::vector<Glib::ustring> mountpoints ;
|
||||
std::vector<Glib::ustring> mountpoints ;//FIXME: it's better to make this one private as well to prevent segfaults
|
||||
//when callong mountpoints .front() on an empty list.
|
||||
|
||||
std::vector<Partition> logicals ;
|
||||
|
||||
bool strict ;
|
||||
|
||||
private:
|
||||
void sort_paths_and_remove_duplicates() ;
|
||||
|
||||
static bool compare_paths( const Glib::ustring & A, const Glib::ustring & B ) ;
|
||||
|
||||
std::vector<Glib::ustring> paths ;
|
||||
};
|
||||
|
||||
}//GParted
|
||||
|
|
|
@ -27,14 +27,63 @@ Device::Device()
|
|||
|
||||
void Device::Reset()
|
||||
{
|
||||
paths .clear() ;
|
||||
partitions .clear() ;
|
||||
length = cylsize = 0 ;
|
||||
heads = sectors = cylinders = 0 ;
|
||||
model = path = realpath = disktype = "" ;
|
||||
model = disktype = "" ;
|
||||
max_prims = highest_busy = 0 ;
|
||||
readonly = false ;
|
||||
}
|
||||
|
||||
void Device::add_path( const Glib::ustring & path, bool clear_paths )
|
||||
{
|
||||
if ( clear_paths )
|
||||
paths .clear() ;
|
||||
|
||||
paths .push_back( path ) ;
|
||||
|
||||
sort_paths_and_remove_duplicates() ;
|
||||
}
|
||||
|
||||
void Device::add_paths( const std::vector<Glib::ustring> & paths, bool clear_paths )
|
||||
{
|
||||
if ( clear_paths )
|
||||
this ->paths .clear() ;
|
||||
|
||||
this ->paths .insert( this ->paths .end(), paths .begin(), paths .end() ) ;
|
||||
|
||||
sort_paths_and_remove_duplicates() ;
|
||||
}
|
||||
|
||||
Glib::ustring Device::get_path()
|
||||
{
|
||||
if ( paths .size() > 0 )
|
||||
return paths .front() ;
|
||||
|
||||
return "" ;
|
||||
}
|
||||
|
||||
std::vector<Glib::ustring> Device::get_paths()
|
||||
{
|
||||
return paths ;
|
||||
}
|
||||
|
||||
void Device::sort_paths_and_remove_duplicates()
|
||||
{
|
||||
//remove duplicates
|
||||
std::sort( paths .begin(), paths .end() ) ;
|
||||
paths .erase( std::unique( paths .begin(), paths .end() ), paths .end() ) ;
|
||||
|
||||
//sort on length
|
||||
std::sort( paths .begin(), paths .end(), compare_paths ) ;
|
||||
}
|
||||
|
||||
bool Device::compare_paths( const Glib::ustring & A, const Glib::ustring & B )
|
||||
{
|
||||
return A .length() < B .length() ;
|
||||
}
|
||||
|
||||
Device::~Device()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ Dialog_Partition_Copy::Dialog_Partition_Copy( const FS & fs, Sector cylinder_siz
|
|||
|
||||
void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, const Partition & copied_partition )
|
||||
{
|
||||
this ->set_title( String::ucompose( _("Paste %1"), copied_partition .partition ) ) ;
|
||||
this ->set_title( String::ucompose( _("Paste %1"), copied_partition .get_path() ) ) ;
|
||||
|
||||
//set partition color
|
||||
frame_resizer_base ->set_rgb_partition_color( copied_partition .color ) ;
|
||||
|
@ -86,6 +86,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
|
||||
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
|
||||
this ->selected_partition = copied_partition ;
|
||||
this ->selected_partition .device_path = selected_partition .device_path ;
|
||||
this ->selected_partition .inside_extended = selected_partition .inside_extended ;
|
||||
this ->selected_partition .type =
|
||||
selected_partition .inside_extended ? GParted::TYPE_LOGICAL : GParted::TYPE_PRIMARY ;
|
||||
|
|
|
@ -28,7 +28,7 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition )
|
|||
this ->set_has_separator( false ) ;
|
||||
|
||||
/*TO TRANSLATORS: dialogtitle, looks like Information about /dev/hda3 */
|
||||
this ->set_title( String::ucompose( _( "Information about %1"), partition .partition ) );
|
||||
this ->set_title( String::ucompose( _( "Information about %1"), partition .get_path() ) );
|
||||
|
||||
init_drawingarea( ) ;
|
||||
|
||||
|
@ -102,6 +102,7 @@ void Dialog_Partition_Info::init_drawingarea( )
|
|||
|
||||
//calculate proportional width of used and unused
|
||||
used = unused = 0 ;
|
||||
//FIXME: use Partition::get_length()..
|
||||
used = Utils::Round( (400 - BORDER *2) / ( static_cast<double>(partition .sector_end - partition .sector_start) / partition .sectors_used ) ) ;
|
||||
unused = 400 - used - BORDER *2 ;
|
||||
|
||||
|
@ -120,7 +121,7 @@ void Dialog_Partition_Info::init_drawingarea( )
|
|||
|
||||
//set text of pangolayout
|
||||
pango_layout = drawingarea .create_pango_layout(
|
||||
partition .partition + "\n" + Utils::format_size( partition .get_length() ) ) ;
|
||||
partition .get_path() + "\n" + Utils::format_size( partition .get_length() ) ) ;
|
||||
}
|
||||
|
||||
void Dialog_Partition_Info::Display_Info( )
|
||||
|
@ -173,19 +174,21 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
if ( partition .type != GParted::TYPE_UNALLOCATED && partition .status != GParted::STAT_NEW )
|
||||
{
|
||||
//path
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Path:" ) + "</b>" ), 0, 1, top, bottom, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( partition .partition ), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
|
||||
//only show realpath if it's diffent from the short path...
|
||||
if ( partition .partition != partition .realpath )
|
||||
{
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Real Path:" ) + "</b>" ), 0, 1, top, bottom, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( partition .realpath ), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
}
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Path:" ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Glib::build_path( "\n", partition .get_paths() ) ),
|
||||
1, 2,
|
||||
top++, bottom++,
|
||||
Gtk::FILL ) ;
|
||||
|
||||
//status
|
||||
Glib::ustring str_temp ;
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Status:" ) + "</b>" ), 0,1, top, bottom, Gtk::FILL) ;
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Status:" ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL) ;
|
||||
if ( partition .busy )
|
||||
{
|
||||
if ( partition .type == GParted::TYPE_EXTENDED )
|
||||
|
@ -219,15 +222,16 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
|
||||
//total sectors
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Total Sectors:" ) + "</b>" ), 0, 1, top, bottom, Gtk::FILL ) ;
|
||||
//FIXME: use Partition::get_length() here..
|
||||
table ->attach( * Utils::mk_label( Utils::num_to_str( partition .sector_end - partition .sector_start ) ), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
}
|
||||
|
||||
Dialog_Partition_Info::~Dialog_Partition_Info( )
|
||||
Dialog_Partition_Info::~Dialog_Partition_Info()
|
||||
{
|
||||
this ->get_colormap( ) ->free_colors( color_used, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_unused, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_text, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_partition, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_used, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_unused, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_text, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_partition, 1 ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -66,12 +66,12 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
|
|||
//see if we need a fixed_start
|
||||
if ( fs .move )
|
||||
{
|
||||
this ->set_title( String::ucompose( _("Resize/Move %1"), selected_partition .partition ) ) ;
|
||||
set_title( String::ucompose( _("Resize/Move %1"), selected_partition .get_path() ) ) ;
|
||||
frame_resizer_base ->set_fixed_start( false ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
this ->set_title( String::ucompose( _("Resize %1"), selected_partition .partition) ) ;
|
||||
set_title( String::ucompose( _("Resize %1"), selected_partition .get_path() ) ) ;
|
||||
this ->fixed_start = true;
|
||||
frame_resizer_base ->set_fixed_start( true ) ;
|
||||
spinbutton_before .set_sensitive( false ) ;
|
||||
|
|
|
@ -84,6 +84,8 @@ void DrawingAreaVisualDisk::set_static_data( const std::vector<Partition> & part
|
|||
{
|
||||
Sector p_length ;
|
||||
visual_partition vp ;
|
||||
//FIXME: any particular reason why Partition::get_length() isn't used in this function?
|
||||
//i'm also not sure why we use 'vp' this way.. Lets either use it or drop it :)
|
||||
|
||||
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
|
||||
{
|
||||
|
@ -109,7 +111,7 @@ void DrawingAreaVisualDisk::set_static_data( const std::vector<Partition> & part
|
|||
partitions[ t ] .sector_end - partitions[ t ] .sector_start ) ;
|
||||
else
|
||||
visual_partitions .back() .pango_layout = create_pango_layout(
|
||||
partitions[ t ] .partition + "\n" + Utils::format_size( partitions[ t ] .get_length() ) ) ;
|
||||
partitions[ t ] .get_path() + "\n" + Utils::format_size( partitions[ t ] .get_length() ) ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ GParted_Core::GParted_Core()
|
|||
|
||||
ped_exception_set_handler( ped_exception_handler ) ;
|
||||
|
||||
|
||||
//get valid flags ...
|
||||
for ( PedPartitionFlag flag = ped_partition_flag_next( static_cast<PedPartitionFlag>( NULL ) ) ;
|
||||
flag ;
|
||||
|
@ -128,8 +127,9 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
|
|||
temp_device .Reset() ;
|
||||
|
||||
//device info..
|
||||
temp_device .path = get_short_path( device_paths[ t ] ) ;
|
||||
temp_device .realpath = lp_device ->path ;
|
||||
temp_device .add_path( device_paths[ t ] ) ;
|
||||
temp_device .add_paths( get_alternate_paths( temp_device .get_path() ) ) ;
|
||||
|
||||
temp_device .model = lp_device ->model ;
|
||||
temp_device .heads = lp_device ->bios_geom .heads ;
|
||||
temp_device .sectors = lp_device ->bios_geom .sectors ;
|
||||
|
@ -148,7 +148,6 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
|
|||
temp_device .max_prims = ped_disk_get_max_primary_partition_count( lp_disk ) ;
|
||||
|
||||
set_device_partitions( temp_device ) ;
|
||||
set_short_paths( temp_device .partitions ) ;
|
||||
set_mountpoints( temp_device .partitions ) ;
|
||||
set_used_sectors( temp_device .partitions ) ;
|
||||
|
||||
|
@ -162,7 +161,10 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
|
|||
temp_device .max_prims = -1 ;
|
||||
|
||||
Partition partition_temp ;
|
||||
partition_temp .Set_Unallocated( temp_device .path, 0, temp_device .length, false );
|
||||
partition_temp .Set_Unallocated( temp_device .get_path(),
|
||||
0,
|
||||
temp_device .length,
|
||||
false );
|
||||
temp_device .partitions .push_back( partition_temp );
|
||||
}
|
||||
|
||||
|
@ -174,7 +176,7 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
|
|||
|
||||
//clear leftover information...
|
||||
//NOTE that we cannot clear mountinfo since it might be needed in get_all_mountpoints()
|
||||
short_paths .clear() ;
|
||||
alternate_paths .clear() ;
|
||||
fstab_info .clear() ;
|
||||
}
|
||||
|
||||
|
@ -208,7 +210,7 @@ void GParted_Core::read_mountpoints_from_file( const Glib::ustring & filename,
|
|||
|
||||
void GParted_Core::init_maps()
|
||||
{
|
||||
short_paths .clear() ;
|
||||
alternate_paths .clear() ;
|
||||
mount_info .clear() ;
|
||||
fstab_info .clear() ;
|
||||
|
||||
|
@ -226,7 +228,7 @@ void GParted_Core::init_maps()
|
|||
iter_mp ->second .end() ) ;
|
||||
}
|
||||
|
||||
//initialize shortpaths...
|
||||
//initialize alternate_paths...
|
||||
std::string line ;
|
||||
std::ifstream proc_partitions( "/proc/partitions" ) ;
|
||||
if ( proc_partitions )
|
||||
|
@ -239,8 +241,13 @@ void GParted_Core::init_maps()
|
|||
line = "/dev/" ;
|
||||
line += c_str ;
|
||||
|
||||
if ( realpath( line .c_str(), c_str ) )
|
||||
short_paths[ c_str ] = line ;
|
||||
if ( realpath( line .c_str(), c_str ) && line != c_str )
|
||||
{
|
||||
//because we can make no assumption about which path libparted will detect
|
||||
//we add all combinations.
|
||||
alternate_paths[ c_str ] = line ;
|
||||
alternate_paths[ line ] = c_str ;
|
||||
}
|
||||
}
|
||||
|
||||
proc_partitions .close() ;
|
||||
|
@ -320,16 +327,18 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
{
|
||||
case PED_PARTITION_NORMAL:
|
||||
case PED_PARTITION_LOGICAL:
|
||||
partition_temp .Set( device .path,
|
||||
partition_temp .Set( device .get_path(),
|
||||
ped_partition_get_path( lp_partition ),
|
||||
lp_partition ->num,
|
||||
lp_partition ->type == 0 ? GParted::TYPE_PRIMARY : GParted::TYPE_LOGICAL,
|
||||
lp_partition ->type == 0 ?
|
||||
GParted::TYPE_PRIMARY : GParted::TYPE_LOGICAL,
|
||||
get_filesystem(),
|
||||
lp_partition ->geom .start,
|
||||
lp_partition ->geom .end,
|
||||
lp_partition ->type,
|
||||
ped_partition_is_busy( lp_partition ) );
|
||||
|
||||
partition_temp .add_paths( get_alternate_paths( partition_temp .get_path() ) ) ;
|
||||
set_flags( partition_temp ) ;
|
||||
|
||||
if ( partition_temp .busy && partition_temp .partition_number > device .highest_busy )
|
||||
|
@ -338,7 +347,7 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
break ;
|
||||
|
||||
case PED_PARTITION_EXTENDED:
|
||||
partition_temp.Set( device .path,
|
||||
partition_temp .Set( device .get_path(),
|
||||
ped_partition_get_path( lp_partition ),
|
||||
lp_partition ->num,
|
||||
GParted::TYPE_EXTENDED,
|
||||
|
@ -348,7 +357,9 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
false,
|
||||
ped_partition_is_busy( lp_partition ) );
|
||||
|
||||
partition_temp .add_paths( get_alternate_paths( partition_temp .get_path() ) ) ;
|
||||
set_flags( partition_temp ) ;
|
||||
|
||||
EXT_INDEX = device .partitions .size() ;
|
||||
break ;
|
||||
|
||||
|
@ -370,13 +381,13 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
}
|
||||
|
||||
if ( EXT_INDEX > -1 )
|
||||
insert_unallocated( device .path,
|
||||
insert_unallocated( device .get_path(),
|
||||
device .partitions[ EXT_INDEX ] .logicals,
|
||||
device .partitions[ EXT_INDEX ] .sector_start,
|
||||
device .partitions[ EXT_INDEX ] .sector_end,
|
||||
true ) ;
|
||||
|
||||
insert_unallocated( device .path, device .partitions, 0, device .length -1, false ) ;
|
||||
insert_unallocated( device .get_path(), device .partitions, 0, device .length -1, false ) ;
|
||||
}
|
||||
|
||||
void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
|
||||
|
@ -389,15 +400,22 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
|
|||
{
|
||||
if ( partitions[ t ] .busy )
|
||||
{
|
||||
iter_mp = mount_info .find( partitions[ t ] .partition );
|
||||
for ( unsigned int i = 0 ; i < partitions[ t ] .get_paths() .size() ; i++ )
|
||||
{
|
||||
iter_mp = mount_info .find( partitions[ t ] .get_paths()[ i ] ) ;
|
||||
if ( iter_mp != mount_info .end() )
|
||||
{
|
||||
partitions[ t ] .mountpoints = iter_mp ->second ;
|
||||
else
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( partitions[ t ] .mountpoints .empty() )
|
||||
partitions[ t ] .error = _("Unable to find mountpoint") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
iter_mp = fstab_info .find( partitions[ t ] .partition );
|
||||
iter_mp = fstab_info .find( partitions[ t ] .get_path() );
|
||||
if ( iter_mp != fstab_info .end() )
|
||||
partitions[ t ] .mountpoints = iter_mp ->second ;
|
||||
}
|
||||
|
@ -407,24 +425,15 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
|
|||
}
|
||||
}
|
||||
|
||||
void GParted_Core::set_short_paths( std::vector<Partition> & partitions )
|
||||
std::vector<Glib::ustring> GParted_Core::get_alternate_paths( const Glib::ustring & path )
|
||||
{
|
||||
for ( unsigned int t =0 ; t < partitions .size() ; t++ )
|
||||
{
|
||||
partitions[ t ] .partition = get_short_path( partitions[ t ] .partition ) ;
|
||||
std::vector<Glib::ustring> paths ;
|
||||
|
||||
if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
|
||||
set_short_paths( partitions[ t ] .logicals ) ;
|
||||
}
|
||||
}
|
||||
iter = alternate_paths .find( path ) ;
|
||||
if ( iter != alternate_paths .end() )
|
||||
paths .push_back( iter ->second ) ;
|
||||
|
||||
Glib::ustring GParted_Core::get_short_path( const Glib::ustring & real_path )
|
||||
{
|
||||
iter = short_paths .find( real_path );
|
||||
if ( iter != short_paths .end() )
|
||||
return iter ->second ;
|
||||
|
||||
return real_path ;
|
||||
return paths ;
|
||||
}
|
||||
|
||||
void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
|
||||
|
@ -686,15 +695,13 @@ bool GParted_Core::copy( const Glib::ustring & src_part_path,
|
|||
std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
set_proper_filesystem( partition_dest .filesystem ) ;
|
||||
|
||||
Partition src_partition ;
|
||||
src_partition .partition = src_part_path ;
|
||||
Partition src_partition( src_part_path ) ;
|
||||
|
||||
return ( p_filesystem &&
|
||||
p_filesystem ->Check_Repair( src_partition, operation_details ) &&
|
||||
create_empty_partition( partition_dest, operation_details, true ) > 0 &&
|
||||
set_partition_type( partition_dest, operation_details ) &&
|
||||
p_filesystem ->Copy( src_part_path, partition_dest .partition, operation_details ) &&
|
||||
p_filesystem ->Copy( src_part_path, partition_dest .get_path(), operation_details ) &&
|
||||
p_filesystem ->Check_Repair( partition_dest, operation_details ) ) ;
|
||||
}
|
||||
|
||||
|
@ -827,6 +834,7 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
NULL,
|
||||
new_partition .sector_start,
|
||||
new_partition .sector_end ) ;
|
||||
|
||||
if ( lp_partition )
|
||||
{
|
||||
if ( new_partition .strict )
|
||||
|
@ -843,12 +851,14 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
|
||||
if ( constraint )
|
||||
{
|
||||
//FIXME: i should use the length of the copied partition as min_size
|
||||
//maybe we can set the used from new_partition to this size?
|
||||
if ( copy )
|
||||
constraint ->min_size = new_partition .get_length() ;
|
||||
|
||||
if ( ped_disk_add_partition( lp_disk, lp_partition, constraint ) && commit() )
|
||||
{
|
||||
new_partition .partition = ped_partition_get_path( lp_partition ) ;
|
||||
new_partition .add_path( ped_partition_get_path( lp_partition ), true ) ;
|
||||
new_partition .partition_number = lp_partition ->num ;
|
||||
|
||||
Sector start = lp_partition ->geom .start ;
|
||||
|
@ -857,7 +867,7 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails(
|
||||
"<i>" +
|
||||
String::ucompose( _("path: %1"), new_partition .partition ) + "\n" +
|
||||
String::ucompose( _("path: %1"), new_partition .get_path() ) + "\n" +
|
||||
String::ucompose( _("start: %1"), start ) + "\n" +
|
||||
String::ucompose( _("end: %1"), end ) + "\n" +
|
||||
String::ucompose( _("size: %1"), Utils::format_size( end - start + 1 ) ) +
|
||||
|
@ -877,7 +887,7 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
(
|
||||
new_partition .type == GParted::TYPE_EXTENDED ||
|
||||
(
|
||||
wait_for_node( new_partition .partition ) &&
|
||||
wait_for_node( new_partition .get_path() ) &&
|
||||
erase_filesystem_signatures( new_partition )
|
||||
)
|
||||
)
|
||||
|
@ -992,7 +1002,7 @@ bool GParted_Core::resize_container_partition( const Partition & partition_old,
|
|||
}
|
||||
else
|
||||
{
|
||||
return_value &= wait_for_node( partition_new .partition ) ;
|
||||
return_value &= wait_for_node( partition_new .get_path() ) ;
|
||||
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
|
||||
|
||||
return return_value ;
|
||||
|
@ -1108,7 +1118,7 @@ bool GParted_Core::set_partition_type( const Partition & partition,
|
|||
(partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
|
||||
if ( lp_partition && ped_partition_set_system( lp_partition, fs_type ) && commit() )
|
||||
return_value = wait_for_node( partition .partition ) ;
|
||||
return_value = wait_for_node( partition .get_path() ) ;
|
||||
}
|
||||
|
||||
close_device_and_disk() ;
|
||||
|
@ -1217,5 +1227,4 @@ PedExceptionOption GParted_Core::ped_exception_handler( PedException * e )
|
|||
return PED_EXCEPTION_UNHANDLED ;
|
||||
}
|
||||
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -23,7 +23,10 @@ Operation::Operation()
|
|||
{
|
||||
}
|
||||
|
||||
Operation::Operation( const Device & device, const Partition & partition_original, const Partition & partition_new, OperationType operationtype )
|
||||
Operation::Operation( const Device & device,
|
||||
const Partition & partition_original,
|
||||
const Partition & partition_new,
|
||||
OperationType operationtype )
|
||||
{
|
||||
this ->device = device ;
|
||||
this ->partition_original = partition_original;
|
||||
|
@ -34,8 +37,10 @@ Operation::Operation( const Device & device, const Partition & partition_origina
|
|||
|
||||
if ( operationtype == COPY )
|
||||
{
|
||||
copied_partition_path = partition_new .partition ;
|
||||
this ->partition_new .partition = String::ucompose( _("copy of %1"), this ->partition_new .partition );
|
||||
copied_partition_path = partition_new .get_path() ;
|
||||
this ->partition_new .add_path(
|
||||
String::ucompose( _("copy of %1"), this ->partition_new .get_path() ),
|
||||
true ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,14 +55,14 @@ Glib::ustring Operation::Get_String( )
|
|||
if (partition_original.type == GParted::TYPE_LOGICAL)
|
||||
temp = _("Logical Partition") ;
|
||||
else
|
||||
temp = partition_original .partition ;
|
||||
temp = partition_original .get_path() ;
|
||||
|
||||
/*TO TRANSLATORS: looks like Delete /dev/hda2 (ntfs, 345 MiB) from /dev/hda */
|
||||
return String::ucompose( _("Delete %1 (%2, %3) from %4"),
|
||||
temp,
|
||||
Utils::Get_Filesystem_String( partition_original .filesystem ),
|
||||
Utils::format_size( partition_original .get_length() ),
|
||||
device .path ) ;
|
||||
device .get_path() ) ;
|
||||
|
||||
case CREATE :
|
||||
switch( partition_new.type )
|
||||
|
@ -78,10 +83,10 @@ Glib::ustring Operation::Get_String( )
|
|||
/*TO TRANSLATORS: looks like Create Logical Partition #1 (ntfs, 345 MiB) on /dev/hda */
|
||||
return String::ucompose( _("Create %1 #%2 (%3, %4) on %5"),
|
||||
temp,
|
||||
partition_new.partition_number,
|
||||
Utils::Get_Filesystem_String( partition_new.filesystem ),
|
||||
partition_new .partition_number,
|
||||
Utils::Get_Filesystem_String( partition_new .filesystem ),
|
||||
Utils::format_size( partition_new .get_length() ),
|
||||
device .path ) ;
|
||||
device .get_path() ) ;
|
||||
|
||||
case RESIZE_MOVE:
|
||||
//if startsector has changed we consider it a move
|
||||
|
@ -90,11 +95,11 @@ Glib::ustring Operation::Get_String( )
|
|||
{
|
||||
if ( partition_new .sector_start > partition_original .sector_start )
|
||||
temp = String::ucompose( _("Move %1 forward by %2"),
|
||||
partition_new .partition,
|
||||
partition_new .get_path(),
|
||||
Utils::format_size( diff ) ) ;
|
||||
else
|
||||
temp = String::ucompose( _("Move %1 backward by %2"),
|
||||
partition_new .partition,
|
||||
partition_new .get_path(),
|
||||
Utils::format_size( diff ) ) ;
|
||||
}
|
||||
|
||||
|
@ -104,12 +109,12 @@ Glib::ustring Operation::Get_String( )
|
|||
{
|
||||
if ( temp .empty() )
|
||||
temp = String::ucompose( _("Resize %1 from %2 to %3"),
|
||||
partition_new.partition,
|
||||
partition_new .get_path(),
|
||||
Utils::format_size( partition_original .get_length() ),
|
||||
Utils::format_size( partition_new .get_length() ) ) ;
|
||||
else
|
||||
temp += " " + String::ucompose( _("and Resize %1 from %2 to %3"),
|
||||
partition_new.partition,
|
||||
partition_new .get_path(),
|
||||
Utils::format_size( partition_original .get_length() ),
|
||||
Utils::format_size( partition_new .get_length() ) ) ;
|
||||
}
|
||||
|
@ -119,14 +124,14 @@ Glib::ustring Operation::Get_String( )
|
|||
case FORMAT :
|
||||
/*TO TRANSLATORS: looks like Format /dev/hda4 as linux-swap */
|
||||
return String::ucompose( _("Format %1 as %2"),
|
||||
partition_original .partition,
|
||||
partition_original .get_path(),
|
||||
Utils::Get_Filesystem_String( partition_new .filesystem ) ) ;
|
||||
|
||||
case COPY :
|
||||
/*TO TRANSLATORS: looks like Copy /dev/hda4 to /dev/hdd (start at 250 MiB) */
|
||||
return String::ucompose( _("Copy %1 to %2 (start at %3)"),
|
||||
partition_new .partition,
|
||||
device .path,
|
||||
partition_new .get_path(),
|
||||
device .get_path(),
|
||||
Utils::format_size( partition_new .sector_start ) ) ;
|
||||
|
||||
default :
|
||||
|
@ -153,7 +158,7 @@ void Operation::Apply_Operation_To_Visual( std::vector<Partition> & partitions )
|
|||
void Operation::Insert_Unallocated( std::vector<Partition> & partitions, Sector start, Sector end, bool inside_extended )
|
||||
{
|
||||
Partition UNALLOCATED ;
|
||||
UNALLOCATED .Set_Unallocated( device .path, 0, 0, inside_extended ) ;
|
||||
UNALLOCATED .Set_Unallocated( device .get_path(), 0, 0, inside_extended ) ;
|
||||
|
||||
//if there are no partitions at all..
|
||||
if ( partitions .empty( ) )
|
||||
|
@ -244,7 +249,10 @@ void Operation::Apply_Delete_To_Visual( std::vector<Partition> & partitions )
|
|||
partitions[ ext ] .logicals[ t ] .Update_Number( partitions[ ext ] .logicals[ t ] .partition_number -1 );
|
||||
|
||||
|
||||
Insert_Unallocated( partitions[ ext ] .logicals, partitions[ ext ] .sector_start, partitions[ ext ] .sector_end, true ) ;
|
||||
Insert_Unallocated( partitions[ ext ] .logicals,
|
||||
partitions[ ext ] .sector_start,
|
||||
partitions[ ext ] .sector_end,
|
||||
true ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,7 +269,10 @@ void Operation::Apply_Create_To_Visual( std::vector<Partition> & partitions )
|
|||
unsigned int ext = get_index_extended( partitions ) ;
|
||||
partitions[ ext ] .logicals[ Get_Index_Original( partitions[ ext ] .logicals ) ] = partition_new ;
|
||||
|
||||
Insert_Unallocated( partitions[ ext ] .logicals, partitions[ ext ] .sector_start, partitions[ ext ] .sector_end, true ) ;
|
||||
Insert_Unallocated( partitions[ ext ] .logicals,
|
||||
partitions[ ext ] .sector_start,
|
||||
partitions[ ext ] .sector_end,
|
||||
true ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,13 +296,18 @@ void Operation::Apply_Resize_Move_Extended_To_Visual( std::vector<Partition> & p
|
|||
//stuff INSIDE extended partition
|
||||
ext = get_index_extended( partitions ) ;
|
||||
|
||||
if ( partitions[ ext ] .logicals .size( ) && partitions[ ext ] .logicals .front( ) .type == GParted::TYPE_UNALLOCATED )
|
||||
partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .begin( ) ) ;
|
||||
if ( partitions[ ext ] .logicals .size() &&
|
||||
partitions[ ext ] .logicals .front() .type == GParted::TYPE_UNALLOCATED )
|
||||
partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .begin() ) ;
|
||||
|
||||
if ( partitions[ ext ] .logicals .size( ) && partitions[ ext ] .logicals .back( ) .type == GParted::TYPE_UNALLOCATED )
|
||||
partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .end( ) -1 ) ;
|
||||
if ( partitions[ ext ] .logicals .size() &&
|
||||
partitions[ ext ] .logicals .back() .type == GParted::TYPE_UNALLOCATED )
|
||||
partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .end() -1 ) ;
|
||||
|
||||
Insert_Unallocated( partitions[ ext ] .logicals, partitions[ ext ] .sector_start, partitions[ ext ] .sector_end, true ) ;
|
||||
Insert_Unallocated( partitions[ ext ] .logicals,
|
||||
partitions[ ext ] .sector_start,
|
||||
partitions[ ext ] .sector_end,
|
||||
true ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -25,9 +25,17 @@ Partition::Partition()
|
|||
Reset() ;
|
||||
}
|
||||
|
||||
Partition::Partition( const Glib::ustring & path )
|
||||
{
|
||||
Reset() ;
|
||||
|
||||
paths .push_back( path ) ;
|
||||
}
|
||||
|
||||
void Partition::Reset()
|
||||
{
|
||||
partition = realpath = error = "" ;
|
||||
paths .clear() ;
|
||||
error .clear() ;
|
||||
status = GParted::STAT_REAL ;
|
||||
type = GParted::TYPE_UNALLOCATED ;
|
||||
filesystem = GParted::FS_UNALLOCATED ;
|
||||
|
@ -50,7 +58,9 @@ void Partition::Set( const Glib::ustring & device_path,
|
|||
bool busy )
|
||||
{
|
||||
this ->device_path = device_path ;
|
||||
this ->partition = realpath = partition;
|
||||
|
||||
paths .push_back( partition ) ;
|
||||
|
||||
this ->partition_number = partition_number;
|
||||
this ->type = type;
|
||||
this ->filesystem = filesystem;
|
||||
|
@ -59,7 +69,7 @@ void Partition::Set( const Glib::ustring & device_path,
|
|||
this ->inside_extended = inside_extended;
|
||||
this ->busy = busy;
|
||||
|
||||
this ->color.set( Utils::Get_Color( filesystem ) );
|
||||
this ->color .set( Utils::Get_Color( filesystem ) );
|
||||
}
|
||||
|
||||
void Partition::Set_Unused( Sector sectors_unused )
|
||||
|
@ -71,7 +81,10 @@ void Partition::Set_Unused( Sector sectors_unused )
|
|||
}
|
||||
}
|
||||
|
||||
void Partition::Set_Unallocated( const Glib::ustring & device_path, Sector sector_start, Sector sector_end, bool inside_extended )
|
||||
void Partition::Set_Unallocated( const Glib::ustring & device_path,
|
||||
Sector sector_start,
|
||||
Sector sector_end,
|
||||
bool inside_extended )
|
||||
{
|
||||
Reset() ;
|
||||
|
||||
|
@ -90,11 +103,38 @@ void Partition::Set_Unallocated( const Glib::ustring & device_path, Sector secto
|
|||
|
||||
void Partition::Update_Number( int new_number )
|
||||
{
|
||||
this ->partition =
|
||||
partition .substr( 0, partition .find( Utils::num_to_str( partition_number ) ) ) +
|
||||
Utils::num_to_str( new_number ) ;
|
||||
unsigned int index ;
|
||||
for ( unsigned int t = 0 ; t < paths .size() ; t++ )
|
||||
{
|
||||
index = paths[ t ] .rfind( Utils::num_to_str( partition_number ) ) ;
|
||||
|
||||
this ->partition_number = new_number;
|
||||
if ( index < paths[ t ] .length() )
|
||||
paths[ t ] .replace( index,
|
||||
Utils::num_to_str( partition_number ) .length(),
|
||||
Utils::num_to_str( new_number ) ) ;
|
||||
}
|
||||
|
||||
partition_number = new_number;
|
||||
}
|
||||
|
||||
void Partition::add_path( const Glib::ustring & path, bool clear_paths )
|
||||
{
|
||||
if ( clear_paths )
|
||||
paths .clear() ;
|
||||
|
||||
paths .push_back( path ) ;
|
||||
|
||||
sort_paths_and_remove_duplicates() ;
|
||||
}
|
||||
|
||||
void Partition::add_paths( const std::vector<Glib::ustring> & paths, bool clear_paths )
|
||||
{
|
||||
if ( clear_paths )
|
||||
this ->paths .clear() ;
|
||||
|
||||
this ->paths .insert( this ->paths .end(), paths .begin(), paths .end() ) ;
|
||||
|
||||
sort_paths_and_remove_duplicates() ;
|
||||
}
|
||||
|
||||
Sector Partition::get_length() const
|
||||
|
@ -102,6 +142,19 @@ Sector Partition::get_length() const
|
|||
return sector_end - sector_start + 1 ;
|
||||
}
|
||||
|
||||
Glib::ustring Partition::get_path() const
|
||||
{
|
||||
if ( paths .size() > 0 )
|
||||
return paths .front() ;
|
||||
|
||||
return "" ;
|
||||
}
|
||||
|
||||
std::vector<Glib::ustring> Partition::get_paths() const
|
||||
{
|
||||
return paths ;
|
||||
}
|
||||
|
||||
bool Partition::operator==( const Partition & partition ) const
|
||||
{
|
||||
return this ->partition_number == partition .partition_number &&
|
||||
|
@ -109,6 +162,21 @@ bool Partition::operator==( const Partition & partition ) const
|
|||
this ->type == partition .type ;
|
||||
}
|
||||
|
||||
void Partition::sort_paths_and_remove_duplicates()
|
||||
{
|
||||
//remove duplicates
|
||||
std::sort( paths .begin(), paths .end() ) ;
|
||||
paths .erase( std::unique( paths .begin(), paths .end() ), paths .end() ) ;
|
||||
|
||||
//sort on length
|
||||
std::sort( paths .begin(), paths .end(), compare_paths ) ;
|
||||
}
|
||||
|
||||
bool Partition::compare_paths( const Glib::ustring & A, const Glib::ustring & B )
|
||||
{
|
||||
return A .length() < B .length() ;
|
||||
}
|
||||
|
||||
Partition::~Partition()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition
|
|||
treerow[ treeview_detail_columns .error_icon ] =
|
||||
render_icon( Gtk::Stock::DIALOG_WARNING, Gtk::ICON_SIZE_BUTTON );
|
||||
|
||||
treerow[ treeview_detail_columns .path ] = partition .partition ;
|
||||
treerow[ treeview_detail_columns .path ] = partition .get_path() ;
|
||||
|
||||
//this fixes a weird issue (see #169683 for more info)
|
||||
if ( partition .type == GParted::TYPE_EXTENDED && partition .busy )
|
||||
|
|
14
src/Utils.cc
14
src/Utils.cc
|
@ -28,15 +28,17 @@ Sector Utils::Round( double double_value )
|
|||
return static_cast<Sector>( double_value + 0.5 ) ;
|
||||
}
|
||||
|
||||
Gtk::Label * Utils::mk_label( const Glib::ustring & text, bool use_markup, bool align_left, bool wrap, const Glib::ustring & text_color )
|
||||
Gtk::Label * Utils::mk_label( const Glib::ustring & text,
|
||||
bool use_markup,
|
||||
bool align_left,
|
||||
bool wrap,
|
||||
const Glib::ustring & text_color )
|
||||
{
|
||||
Gtk::Label * label = manage( new Gtk::Label( text ) ) ;
|
||||
Gtk::Label * label = manage( new Gtk::Label( text,
|
||||
align_left ? Gtk::ALIGN_LEFT : Gtk::ALIGN_CENTER,
|
||||
Gtk::ALIGN_TOP ) ) ;
|
||||
|
||||
label ->set_use_markup( use_markup ) ;
|
||||
|
||||
if ( align_left )
|
||||
label ->set_alignment( Gtk::ALIGN_LEFT ) ;
|
||||
|
||||
label ->set_line_wrap( wrap ) ;
|
||||
|
||||
if ( text_color != "black" )
|
||||
|
|
|
@ -321,11 +321,6 @@ void Win_GParted::init_device_info()
|
|||
device_info .push_back( Utils::mk_label( "" ) ) ;
|
||||
table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL);
|
||||
|
||||
//real path
|
||||
table ->attach( * Utils::mk_label( " <b>" + (Glib::ustring) _( "Real Path:" ) + "</b>" ) , 0,1,top, bottom ,Gtk::FILL);
|
||||
device_info .push_back( Utils::mk_label( "" ) ) ;
|
||||
table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL);
|
||||
|
||||
vbox_info .pack_start( *table, Gtk::PACK_SHRINK );
|
||||
|
||||
//DETAILED DEVICE INFO
|
||||
|
@ -441,13 +436,13 @@ void Win_GParted::refresh_combo_devices()
|
|||
treerow = *( liststore_devices ->append() ) ;
|
||||
treerow[ treeview_devices_columns .icon ] =
|
||||
render_icon( Gtk::Stock::HARDDISK, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ;
|
||||
treerow[ treeview_devices_columns .device ] = devices[ i ] .path ;
|
||||
treerow[ treeview_devices_columns .device ] = devices[ i ] .get_path() ;
|
||||
treerow[ treeview_devices_columns .size ] = "(" + Utils::format_size( devices[ i ] .length ) + ")" ;
|
||||
|
||||
//devices submenu....
|
||||
menu ->items() .push_back( Gtk::Menu_Helpers::RadioMenuElem(
|
||||
radio_group,
|
||||
devices[ i ] .path + "\t(" + Utils::format_size( devices[ i ] .length ) + ")",
|
||||
devices[ i ] .get_path() + "\t(" + Utils::format_size( devices[ i ] .length ) + ")",
|
||||
sigc::bind<unsigned int>( sigc::mem_fun(*this, &Win_GParted::radio_devices_changed), i ) ) ) ;
|
||||
}
|
||||
|
||||
|
@ -510,8 +505,7 @@ void Win_GParted::Fill_Label_Device_Info( bool clear )
|
|||
//global info...
|
||||
device_info[ t++ ] ->set_text( devices[ current_device ] .model ) ;
|
||||
device_info[ t++ ] ->set_text( Utils::format_size( devices[ current_device ] .length ) ) ;
|
||||
device_info[ t++ ] ->set_text( devices[ current_device ] .path ) ;
|
||||
device_info[ t++ ] ->set_text( devices[ current_device ] .realpath ) ;
|
||||
device_info[ t++ ] ->set_text( Glib::build_path( "\n", devices[ current_device ] .get_paths() ) ) ;
|
||||
|
||||
//detailed info
|
||||
device_info[ t++ ] ->set_text( devices[ current_device ] .disktype ) ;
|
||||
|
@ -578,8 +572,8 @@ void Win_GParted::Refresh_Visual()
|
|||
|
||||
//make all operations visible
|
||||
for ( unsigned int t = 0 ; t < operations .size(); t++ )
|
||||
{
|
||||
if ( operations[ t ] .device .path == devices[ current_device ] .path )
|
||||
{ //FIXME: overload == operator for Device and use that instead of this..
|
||||
if ( operations[ t ] .device .get_path() == devices[ current_device ] .get_path() )
|
||||
operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
|
||||
|
||||
treerow = *( liststore_operations ->append() );
|
||||
|
@ -605,7 +599,7 @@ void Win_GParted::Refresh_Visual()
|
|||
primary_count = 0;
|
||||
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
|
||||
{
|
||||
if ( partitions[ t ] .partition == copied_partition .partition )
|
||||
if ( partitions[ t ] .get_path() == copied_partition .get_path() )
|
||||
copied_partition = partitions[ t ] ;
|
||||
|
||||
switch ( partitions[ t ] .type )
|
||||
|
@ -673,7 +667,7 @@ void Win_GParted::set_valid_operations()
|
|||
dynamic_cast<Gtk::Label*>(menu_partition .items()[ 10 ] .get_child() ) ->set_label( _("unmount") ) ;
|
||||
|
||||
//no partition selected...
|
||||
if ( selected_partition .partition .empty() )
|
||||
if ( ! selected_partition .get_paths() .size() )
|
||||
return ;
|
||||
|
||||
//if there's something, there's some info ;)
|
||||
|
@ -717,7 +711,7 @@ void Win_GParted::set_valid_operations()
|
|||
allow_new( true );
|
||||
|
||||
//find out if there is a copied partition and if it fits inside this unallocated space
|
||||
if ( ! copied_partition .partition .empty() && ! devices[ current_device ] .readonly )
|
||||
if ( ! copied_partition .get_path() .empty() && ! devices[ current_device ] .readonly )
|
||||
{
|
||||
Sector required_size ;
|
||||
if ( copied_partition .filesystem == GParted::FS_XFS )
|
||||
|
@ -824,7 +818,7 @@ void Win_GParted::combo_devices_changed()
|
|||
{
|
||||
//set new current device
|
||||
current_device = combo_devices .get_active_row_number() ;
|
||||
this ->set_title( String::ucompose( _("%1 - GParted"), devices[ current_device ] .path ) );
|
||||
set_title( String::ucompose( _("%1 - GParted"), devices[ current_device ] .get_path() ) );
|
||||
|
||||
//refresh label_device_info
|
||||
Fill_Label_Device_Info();
|
||||
|
@ -876,10 +870,10 @@ void Win_GParted::menu_gparted_refresh_devices( )
|
|||
|
||||
//show read-only warning if necessary
|
||||
Glib::ustring readonly_paths ;
|
||||
|
||||
//FIXME: push relevant devices in vector en construct error using Glib::build_path
|
||||
for ( unsigned int t = 0 ; t < devices .size() ; t++ )
|
||||
if ( devices[ t ] .readonly )
|
||||
readonly_paths += "\n- " + devices[ t ] .path ;
|
||||
readonly_paths += "\n- " + devices[ t ] .get_path() ;
|
||||
|
||||
if ( ! readonly_paths .empty() )
|
||||
{
|
||||
|
@ -901,8 +895,8 @@ void Win_GParted::menu_gparted_refresh_devices( )
|
|||
//but anyone who removes the sourcedevice before applying the operations gets what he/she deserves :-)
|
||||
unsigned int i ;
|
||||
for ( unsigned int t = 0 ; t < operations .size() ; t++ )
|
||||
{
|
||||
for ( i = 0 ; i < devices .size() && devices[ i ] .path != operations[ t ] .device .path ; i++ ) {}
|
||||
{//FIXME same as above, use Device::==
|
||||
for ( i = 0 ; i < devices .size() && devices[ i ] .get_path() != operations[ t ] .device .get_path() ; i++ ) {}
|
||||
|
||||
if ( i >= devices .size() )
|
||||
operations .erase( operations .begin() + t-- ) ;//decrease t bij one..
|
||||
|
@ -1111,10 +1105,10 @@ bool Win_GParted::max_amount_prim_reached()
|
|||
void Win_GParted::activate_resize()
|
||||
{
|
||||
std::vector<Partition> partitions = devices[ current_device ] .partitions ;
|
||||
|
||||
//FIXME use DEvice::==
|
||||
if ( operations .size() )
|
||||
for (unsigned int t = 0 ; t < operations .size() ; t++ )
|
||||
if ( operations[ t ] .device .path == devices[ current_device ] .path )
|
||||
if ( operations[ t ] .device .get_path() == devices[ current_device ] .get_path() )
|
||||
operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
|
||||
|
||||
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( selected_partition .filesystem ),
|
||||
|
@ -1142,7 +1136,7 @@ void Win_GParted::activate_resize()
|
|||
//remove operation which creates this partition
|
||||
for ( unsigned int t = 0 ; t < operations .size() ; t++ )
|
||||
{
|
||||
if ( operations[ t ] .partition_new .partition == selected_partition .partition )
|
||||
if ( operations[ t ] .partition_new == selected_partition )
|
||||
{
|
||||
operations.erase( operations .begin() + t ) ;
|
||||
|
||||
|
@ -1225,7 +1219,7 @@ void Win_GParted::activate_delete()
|
|||
selected_partition .partition_number < devices[ current_device ] .highest_busy )
|
||||
{
|
||||
Gtk::MessageDialog dialog( *this,
|
||||
String::ucompose( _( "Unable to delete %1!"), selected_partition .partition ),
|
||||
String::ucompose( _( "Unable to delete %1!"), selected_partition .get_path() ),
|
||||
false,
|
||||
Gtk::MESSAGE_ERROR,
|
||||
Gtk::BUTTONS_OK,
|
||||
|
@ -1239,12 +1233,12 @@ void Win_GParted::activate_delete()
|
|||
return;
|
||||
}
|
||||
|
||||
//if partition is on the clipboard...
|
||||
if ( selected_partition .partition == copied_partition .partition )
|
||||
//if partition is on the clipboard...(NOTE: we can't use Partition::== here..)
|
||||
if ( selected_partition .get_path() == copied_partition .get_path() )
|
||||
{
|
||||
Gtk::MessageDialog dialog( *this,
|
||||
String::ucompose( _( "Are you sure you want to delete %1?"),
|
||||
selected_partition .partition ),
|
||||
selected_partition .get_path() ),
|
||||
false,
|
||||
Gtk::MESSAGE_QUESTION,
|
||||
Gtk::BUTTONS_NONE,
|
||||
|
@ -1254,7 +1248,7 @@ void Win_GParted::activate_delete()
|
|||
|
||||
/*TO TRANSLATORS: dialogtitle, looks like Delete /dev/hda2 (ntfs, 2345 MiB) */
|
||||
dialog .set_title( String::ucompose( _("Delete %1 (%2, %3)"),
|
||||
selected_partition .partition,
|
||||
selected_partition .get_path(),
|
||||
Utils::Get_Filesystem_String( selected_partition .filesystem ),
|
||||
Utils::format_size( selected_partition .get_length() ) ) );
|
||||
dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
|
||||
|
@ -1267,7 +1261,7 @@ void Win_GParted::activate_delete()
|
|||
}
|
||||
|
||||
//if deleted partition was on the clipboard we erase it...
|
||||
if ( selected_partition .partition == copied_partition .partition )
|
||||
if ( selected_partition .get_path() == copied_partition .get_path() )
|
||||
copied_partition .Reset() ;
|
||||
|
||||
/* if deleted one is NEW, it doesn't make sense to add it to the operationslist,
|
||||
|
@ -1277,7 +1271,7 @@ void Win_GParted::activate_delete()
|
|||
{
|
||||
//remove all operations done on this new partition (this includes creation)
|
||||
for ( int t = 0 ; t < static_cast<int>( operations .size() ) ; t++ )
|
||||
if ( operations[ t ] .partition_new .partition == selected_partition .partition )
|
||||
if ( operations[ t ] .partition_new .get_path() == selected_partition .get_path() )
|
||||
operations.erase( operations .begin() + t-- ) ;
|
||||
|
||||
//determine lowest possible new_count
|
||||
|
@ -1337,9 +1331,9 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
|
|||
}
|
||||
|
||||
//ok we made it. lets create an fitting partition object
|
||||
Partition part_temp;
|
||||
part_temp .Set( devices[ current_device ] .path,
|
||||
selected_partition .partition,
|
||||
Partition part_temp ;
|
||||
part_temp .Set( devices[ current_device ] .get_path(),
|
||||
selected_partition .get_path(),
|
||||
selected_partition .partition_number,
|
||||
selected_partition .type, new_fs,
|
||||
selected_partition .sector_start,
|
||||
|
@ -1355,7 +1349,7 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
|
|||
//remove operation which creates this partition
|
||||
for ( unsigned int t = 0 ; t < operations .size() ; t++ )
|
||||
{
|
||||
if ( operations[ t ] .partition_new .partition == selected_partition .partition )
|
||||
if ( operations[ t ] .partition_new == selected_partition )
|
||||
{
|
||||
operations .erase( operations .begin() +t ) ;
|
||||
|
||||
|
@ -1413,7 +1407,7 @@ void Win_GParted::thread_mount_partition( bool * succes, Glib::ustring * error )
|
|||
|
||||
*succes = true ;
|
||||
for ( unsigned int t = 0 ; t < selected_partition .mountpoints .size() ; t++ )
|
||||
if ( Utils::execute_command( "mount -v " + selected_partition .partition + " " + selected_partition .mountpoints[ t ],
|
||||
if ( Utils::execute_command( "mount -v " + selected_partition .get_path() + " " + selected_partition .mountpoints[ t ],
|
||||
dummy,
|
||||
*error ) )
|
||||
{
|
||||
|
@ -1432,9 +1426,9 @@ void Win_GParted::thread_toggle_swap( bool * succes, Glib::ustring * error )
|
|||
Glib::ustring dummy ;
|
||||
|
||||
if ( selected_partition .busy )
|
||||
*succes = ! Utils::execute_command( "swapoff -v " + selected_partition .partition + " && sync", dummy, *error ) ;
|
||||
*succes = ! Utils::execute_command( "swapoff -v " + selected_partition .get_path() + " && sync", dummy, *error ) ;
|
||||
else
|
||||
*succes = ! Utils::execute_command( "swapon -v " + selected_partition .partition + " && sync", dummy, *error ) ;
|
||||
*succes = ! Utils::execute_command( "swapon -v " + selected_partition .get_path() + " && sync", dummy, *error ) ;
|
||||
|
||||
pulse = false ;
|
||||
}
|
||||
|
@ -1452,8 +1446,9 @@ void Win_GParted::toggle_swap_mount_state()
|
|||
sigc::mem_fun( *this, &Win_GParted::thread_toggle_swap ), &succes, &error ), true ) ;
|
||||
|
||||
show_pulsebar(
|
||||
String::ucompose( selected_partition .busy ? _("Deactivating swap on %1") : _("Activating swap on %1"),
|
||||
selected_partition .partition ) ) ;
|
||||
String::ucompose(
|
||||
selected_partition .busy ? _("Deactivating swap on %1") : _("Activating swap on %1"),
|
||||
selected_partition .get_path() ) ) ;
|
||||
|
||||
if ( ! succes )
|
||||
{
|
||||
|
@ -1477,14 +1472,14 @@ void Win_GParted::toggle_swap_mount_state()
|
|||
thread = Glib::Thread::create( sigc::bind<bool *, Glib::ustring *>(
|
||||
sigc::mem_fun( *this, &Win_GParted::thread_unmount_partition ), &succes, &error ), true ) ;
|
||||
|
||||
show_pulsebar( String::ucompose( _("Unmounting %1"), selected_partition .partition ) ) ;
|
||||
show_pulsebar( String::ucompose( _("Unmounting %1"), selected_partition .get_path() ) ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
thread = Glib::Thread::create( sigc::bind<bool *, Glib::ustring *>(
|
||||
sigc::mem_fun( *this, &Win_GParted::thread_mount_partition ), &succes, &error ), true ) ;
|
||||
|
||||
show_pulsebar( String::ucompose( _("mounting %1"), selected_partition .partition ) ) ;
|
||||
show_pulsebar( String::ucompose( _("mounting %1"), selected_partition .get_path() ) ) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1492,7 +1487,7 @@ void Win_GParted::toggle_swap_mount_state()
|
|||
{
|
||||
Gtk::MessageDialog dialog( *this,
|
||||
String::ucompose( selected_partition .busy ? _("Could not unmount %1") : _("Could not mount %1"),
|
||||
selected_partition .partition ),
|
||||
selected_partition .get_path() ),
|
||||
false,
|
||||
Gtk::MESSAGE_ERROR,
|
||||
Gtk::BUTTONS_OK,
|
||||
|
@ -1509,7 +1504,7 @@ void Win_GParted::toggle_swap_mount_state()
|
|||
|
||||
void Win_GParted::activate_disklabel()
|
||||
{
|
||||
Dialog_Disklabel dialog( devices[ current_device ] .path, gparted_core .get_disklabeltypes() ) ;
|
||||
Dialog_Disklabel dialog( devices[ current_device ] .get_path(), gparted_core .get_disklabeltypes() ) ;
|
||||
dialog .set_transient_for( *this );
|
||||
|
||||
if ( dialog .run() == Gtk::RESPONSE_OK )
|
||||
|
@ -1517,19 +1512,19 @@ void Win_GParted::activate_disklabel()
|
|||
Gtk::MessageDialog m_dialog( *this,
|
||||
String::ucompose( _("Are you sure you want to create a %1 disklabel on %2?"),
|
||||
dialog .Get_Disklabel(),
|
||||
devices[ current_device ] .path ),
|
||||
devices[ current_device ] .get_path() ),
|
||||
false,
|
||||
Gtk::MESSAGE_QUESTION,
|
||||
Gtk::BUTTONS_CANCEL,
|
||||
true ) ;
|
||||
|
||||
m_dialog .set_secondary_text( String::ucompose( _("This operation will destroy all data on %1!"),
|
||||
devices[ current_device ] .path ) ) ;
|
||||
devices[ current_device ] .get_path() ) ) ;
|
||||
|
||||
m_dialog .add_button( _("Create"), Gtk::RESPONSE_OK );
|
||||
|
||||
if ( m_dialog .run() == Gtk::RESPONSE_OK &&
|
||||
! gparted_core .Set_Disklabel( devices[ current_device ] .path, dialog .Get_Disklabel() ) )
|
||||
! gparted_core .Set_Disklabel( devices[ current_device ] .get_path(), dialog .Get_Disklabel() ) )
|
||||
{
|
||||
Gtk::MessageDialog dialog( *this,
|
||||
_("Error while setting new disklabel"),
|
||||
|
|
12
src/ext2.cc
12
src/ext2.cc
|
@ -51,7 +51,7 @@ FS ext2::get_filesystem_support()
|
|||
|
||||
void ext2::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
if ( ! Utils::execute_command( "dumpe2fs -h " + partition .partition, output, error, true ) )
|
||||
if ( ! Utils::execute_command( "dumpe2fs -h " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
index = output .find( "Free blocks:" ) ;
|
||||
if ( index >= output .length() ||
|
||||
|
@ -76,7 +76,7 @@ bool ext2::Create( const Partition & new_partition, std::vector<OperationDetails
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_EXT2 ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mkfs.ext2 " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "mkfs.ext2 " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
@ -97,7 +97,7 @@ bool ext2::Resize( const Partition & partition_new,
|
|||
else
|
||||
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
|
||||
|
||||
Glib::ustring str_temp = "resize2fs " + partition_new .partition ;
|
||||
Glib::ustring str_temp = "resize2fs " + partition_new .get_path() ;
|
||||
|
||||
if ( ! fill_partition )
|
||||
str_temp += " " + Utils::num_to_str( Utils::Round( Utils::sector_to_unit(
|
||||
|
@ -127,9 +127,7 @@ bool ext2::Copy( const Glib::ustring & src_part_path,
|
|||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
Partition partition ;
|
||||
partition .partition = dest_part_path ;
|
||||
return Resize( partition, operation_details, true ) ;
|
||||
return Resize( Partition( dest_part_path ), operation_details, true ) ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
|
@ -140,7 +138,7 @@ bool ext2::Check_Repair( const Partition & partition, std::vector<OperationDetai
|
|||
{
|
||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||
|
||||
if ( 1 >= execute_command( "e2fsck -f -y -v " + partition .partition,
|
||||
if ( 1 >= execute_command( "e2fsck -f -y -v " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) >= 0 )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
|
14
src/ext3.cc
14
src/ext3.cc
|
@ -52,7 +52,7 @@ FS ext3::get_filesystem_support()
|
|||
|
||||
void ext3::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
if ( ! Utils::execute_command( "dumpe2fs -h " + partition .partition, output, error, true ) )
|
||||
if ( ! Utils::execute_command( "dumpe2fs -h " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
index = output .find( "Free blocks:" ) ;
|
||||
if ( index >= output .length() ||
|
||||
|
@ -77,7 +77,7 @@ bool ext3::Create( const Partition & new_partition, std::vector<OperationDetails
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_EXT3 ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mkfs.ext3 " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "mkfs.ext3 " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
@ -98,7 +98,7 @@ bool ext3::Resize( const Partition & partition_new,
|
|||
else
|
||||
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
|
||||
|
||||
Glib::ustring str_temp = "resize2fs " + partition_new .partition ;
|
||||
Glib::ustring str_temp = "resize2fs " + partition_new .get_path() ;
|
||||
|
||||
if ( ! fill_partition )
|
||||
str_temp += " " + Utils::num_to_str( Utils::Round( Utils::sector_to_unit(
|
||||
|
@ -128,9 +128,7 @@ bool ext3::Copy( const Glib::ustring & src_part_path,
|
|||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
Partition partition ;
|
||||
partition .partition = dest_part_path ;
|
||||
return Resize( partition, operation_details, true ) ;
|
||||
return Resize( Partition( dest_part_path ), operation_details, true ) ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
|
@ -140,9 +138,9 @@ bool ext3::Copy( const Glib::ustring & src_part_path,
|
|||
bool ext3::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||
//FIXME: i still need to check if the 1 >= x >= 0 structure actually works!
|
||||
|
||||
|
||||
if ( 1 >= execute_command( "e2fsck -f -y -v " + partition .partition,
|
||||
if ( 1 >= execute_command( "e2fsck -f -y -v " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) >= 0 )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
|
11
src/fat16.cc
11
src/fat16.cc
|
@ -52,11 +52,12 @@ FS fat16::get_filesystem_support()
|
|||
|
||||
void fat16::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
exit_status = Utils::execute_command( "dosfsck -a -v " + partition .partition, output, error, true ) ;
|
||||
exit_status = Utils::execute_command( "dosfsck -a -v " + partition .get_path(), output, error, true ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 )
|
||||
{
|
||||
{//FIXME: does the output of these commands always display the path we've used for the input?
|
||||
//if not, we need to check for all paths in the output..
|
||||
//free clusters
|
||||
index = output .find( ",", output .find( partition .partition ) + partition .partition .length() ) +1 ;
|
||||
index = output .find( ",", output .find( partition .get_path() ) + partition .get_path() .length() ) +1 ;
|
||||
if ( index < output .length() && sscanf( output .substr( index ) .c_str(), "%Ld/%Ld", &S, &N ) == 2 )
|
||||
N -= S ;
|
||||
else
|
||||
|
@ -80,7 +81,7 @@ bool fat16::Create( const Partition & new_partition, std::vector<OperationDetail
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_FAT16 ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mkdosfs -F16 -v " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "mkdosfs -F16 -v " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
@ -124,7 +125,7 @@ bool fat16::Check_Repair( const Partition & partition, std::vector<OperationDeta
|
|||
{
|
||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||
|
||||
exit_status = execute_command( "dosfsck -a -w -v " + partition .partition,
|
||||
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 )
|
||||
{
|
||||
|
|
10
src/fat32.cc
10
src/fat32.cc
|
@ -21,7 +21,7 @@
|
|||
namespace GParted
|
||||
{
|
||||
|
||||
FS fat32::get_filesystem_support( )
|
||||
FS fat32::get_filesystem_support()
|
||||
{
|
||||
FS fs ;
|
||||
fs .filesystem = GParted::FS_FAT32 ;
|
||||
|
@ -51,11 +51,11 @@ FS fat32::get_filesystem_support( )
|
|||
|
||||
void fat32::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
exit_status = Utils::execute_command( "dosfsck -a -v " + partition .partition, output, error, true ) ;
|
||||
exit_status = Utils::execute_command( "dosfsck -a -v " + partition .get_path(), output, error, true ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 )
|
||||
{
|
||||
//free clusters
|
||||
index = output .find( ",", output .find( partition .partition ) + partition .partition .length() ) +1 ;
|
||||
index = output .find( ",", output .find( partition .get_path() ) + partition .get_path() .length() ) +1 ;
|
||||
if ( index < output .length() && sscanf( output .substr( index ) .c_str(), "%Ld/%Ld", &S, &N ) == 2 )
|
||||
N -= S ;
|
||||
else
|
||||
|
@ -79,7 +79,7 @@ bool fat32::Create( const Partition & new_partition, std::vector<OperationDetail
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_FAT32 ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mkdosfs -F32 -v " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "mkdosfs -F32 -v " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
@ -123,7 +123,7 @@ bool fat32::Check_Repair( const Partition & partition, std::vector<OperationDeta
|
|||
{
|
||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||
|
||||
exit_status = execute_command( "dosfsck -a -w -v " + partition .partition,
|
||||
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 )
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ bool hfs::Create( const Partition & new_partition, std::vector<OperationDetails>
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_HFS ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "hformat " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "hformat " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
|
22
src/jfs.cc
22
src/jfs.cc
|
@ -68,7 +68,7 @@ FS jfs::get_filesystem_support()
|
|||
|
||||
void jfs::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
if ( ! Utils::execute_command( "echo dm | jfs_debugfs " + partition .partition, output, error, true ) )
|
||||
if ( ! Utils::execute_command( "echo dm | jfs_debugfs " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
//blocksize
|
||||
index = output .find( "Block Size:" ) ;
|
||||
|
@ -95,7 +95,7 @@ bool jfs::Create( const Partition & new_partition, std::vector<OperationDetails>
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_JFS ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mkfs.jfs -q " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "mkfs.jfs -q " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
@ -129,9 +129,9 @@ bool jfs::Resize( const Partition & partition_new,
|
|||
|
||||
//mount partition
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( String::ucompose( _("mount %1 on %2"), partition_new .partition, TEMP_MP ) ) ) ;
|
||||
OperationDetails( String::ucompose( _("mount %1 on %2"), partition_new .get_path(), TEMP_MP ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mount -v -t jfs " + partition_new .partition + " " + TEMP_MP,
|
||||
if ( ! execute_command( "mount -v -t jfs " + partition_new .get_path() + " " + TEMP_MP,
|
||||
operation_details .back() .sub_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
@ -139,9 +139,9 @@ bool jfs::Resize( const Partition & partition_new,
|
|||
//remount the partition to resize the filesystem
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( String::ucompose( _("remount %1 on %2 with the 'resize' flag enabled"),
|
||||
partition_new .partition, TEMP_MP ) ) ) ;
|
||||
partition_new .get_path(), TEMP_MP ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mount -v -t jfs -o remount,resize " + partition_new .partition + " " + TEMP_MP,
|
||||
if ( ! execute_command( "mount -v -t jfs -o remount,resize " + partition_new .get_path() + " " + TEMP_MP,
|
||||
operation_details .back() .sub_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
@ -154,9 +154,9 @@ bool jfs::Resize( const Partition & partition_new,
|
|||
|
||||
//and unmount it...
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( String::ucompose( _("unmount %1"), partition_new .partition ) ) ) ;
|
||||
OperationDetails( String::ucompose( _("unmount %1"), partition_new .get_path() ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "umount -v " + partition_new .partition,
|
||||
if ( ! execute_command( "umount -v " + partition_new .get_path(),
|
||||
operation_details .back() .sub_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
@ -211,9 +211,7 @@ bool jfs::Copy( const Glib::ustring & src_part_path,
|
|||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
Partition partition ;
|
||||
partition .partition = dest_part_path ;
|
||||
return Resize( partition, operation_details, true ) ;
|
||||
return Resize( Partition( dest_part_path ), operation_details, true ) ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
|
@ -224,7 +222,7 @@ bool jfs::Check_Repair( const Partition & partition, std::vector<OperationDetail
|
|||
{
|
||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||
|
||||
exit_status = execute_command( "jfs_fsck -f " + partition .partition, operation_details .back() .sub_details ) ;
|
||||
exit_status = execute_command( "jfs_fsck -f " + partition .get_path(), operation_details .back() .sub_details ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
|
|
@ -51,7 +51,7 @@ bool linux_swap::Create( const Partition & new_partition, std::vector<OperationD
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_LINUX_SWAP ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mkswap " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "mkswap " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
|
12
src/ntfs.cc
12
src/ntfs.cc
|
@ -53,7 +53,7 @@ FS ntfs::get_filesystem_support()
|
|||
|
||||
void ntfs::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
if ( ! Utils::execute_command( "ntfscluster --force " + partition .partition, output, error, true ) )
|
||||
if ( ! Utils::execute_command( "ntfscluster --force " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
index = output .find( "sectors of free space" ) ;
|
||||
if ( index >= output .length() ||
|
||||
|
@ -73,7 +73,7 @@ bool ntfs::Create( const Partition & new_partition, std::vector<OperationDetails
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_NTFS ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mkntfs -Q -vv " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "mkntfs -Q -vv " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
@ -95,7 +95,7 @@ bool ntfs::Resize( const Partition & partition_new,
|
|||
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
|
||||
|
||||
bool return_value = false ;
|
||||
Glib::ustring str_temp = "ntfsresize -P --force --force " + partition_new .partition ;
|
||||
Glib::ustring str_temp = "ntfsresize -P --force --force " + partition_new .get_path() ;
|
||||
|
||||
if ( ! fill_partition )
|
||||
{
|
||||
|
@ -146,9 +146,7 @@ bool ntfs::Copy( const Glib::ustring & src_part_path,
|
|||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
Partition partition ;
|
||||
partition .partition = dest_part_path ;
|
||||
return Resize( partition, operation_details, true ) ;
|
||||
return Resize( Partition( dest_part_path ), operation_details, true ) ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
|
@ -159,7 +157,7 @@ bool ntfs::Check_Repair( const Partition & partition, std::vector<OperationDetai
|
|||
{
|
||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||
|
||||
if ( ! execute_command( "ntfsresize -P -i -f -v " + partition .partition,
|
||||
if ( ! execute_command( "ntfsresize -P -i -f -v " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
|
|
@ -45,7 +45,7 @@ FS reiser4::get_filesystem_support()
|
|||
|
||||
void reiser4::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
if ( ! Utils::execute_command( "debugfs.reiser4 " + partition .partition, output, error, true ) )
|
||||
if ( ! Utils::execute_command( "debugfs.reiser4 " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
index = output .find( "free blocks" ) ;
|
||||
if ( index >= output .length() ||
|
||||
|
@ -70,7 +70,7 @@ bool reiser4::Create( const Partition & new_partition, std::vector<OperationDeta
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_REISER4 ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mkfs.reiser4 --yes " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "mkfs.reiser4 --yes " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
@ -100,7 +100,7 @@ bool reiser4::Check_Repair( const Partition & partition, std::vector<OperationDe
|
|||
{
|
||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||
|
||||
if ( ! execute_command( "fsck.reiser4 --yes --fix " + partition .partition,
|
||||
if ( ! execute_command( "fsck.reiser4 --yes --fix " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
|
|
@ -55,7 +55,7 @@ FS reiserfs::get_filesystem_support()
|
|||
|
||||
void reiserfs::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
if ( ! Utils::execute_command( "debugreiserfs " + partition .partition, output, error, true ) )
|
||||
if ( ! Utils::execute_command( "debugreiserfs " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
index = output .find( "Blocksize" ) ;
|
||||
if ( index >= output .length() ||
|
||||
|
@ -80,7 +80,7 @@ bool reiserfs::Create( const Partition & new_partition, std::vector<OperationDet
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_REISERFS ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mkreiserfs -f " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "mkreiserfs -f " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
@ -101,7 +101,7 @@ bool reiserfs::Resize( const Partition & partition_new,
|
|||
else
|
||||
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
|
||||
|
||||
Glib::ustring str_temp = "echo y | resize_reiserfs " + partition_new .partition ;
|
||||
Glib::ustring str_temp = "echo y | resize_reiserfs " + partition_new .get_path() ;
|
||||
|
||||
if ( ! fill_partition )
|
||||
{
|
||||
|
@ -134,9 +134,7 @@ bool reiserfs::Copy( const Glib::ustring & src_part_path,
|
|||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
Partition partition ;
|
||||
partition .partition = dest_part_path ;
|
||||
return Resize( partition, operation_details, true ) ;
|
||||
return Resize( Partition( dest_part_path ), operation_details, true ) ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
|
@ -145,9 +143,10 @@ bool reiserfs::Copy( const Glib::ustring & src_part_path,
|
|||
|
||||
bool reiserfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
//FIXME: change this description to 'check filesystem on /dev/blabla for er.. etc..'
|
||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||
|
||||
exit_status = execute_command( "reiserfsck --y --fix-fixable " + partition .partition,
|
||||
exit_status = execute_command( "reiserfsck --y --fix-fixable " + partition .get_path(),
|
||||
operation_details .back() .sub_details ) ;
|
||||
if ( exit_status == 0 || exit_status == 1 || exit_status == 256 )
|
||||
{
|
||||
|
|
17
src/xfs.cc
17
src/xfs.cc
|
@ -70,7 +70,7 @@ FS xfs::get_filesystem_support()
|
|||
void xfs::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
if ( ! Utils::execute_command(
|
||||
"xfs_db -c 'sb 0' -c 'print blocksize' -c 'print fdblocks' -r " + partition .partition,
|
||||
"xfs_db -c 'sb 0' -c 'print blocksize' -c 'print fdblocks' -r " + partition .get_path(),
|
||||
output,
|
||||
error,
|
||||
true ) )
|
||||
|
@ -97,7 +97,7 @@ bool xfs::Create( const Partition & new_partition, std::vector<OperationDetails>
|
|||
_("create new %1 filesystem"),
|
||||
Utils::Get_Filesystem_String( GParted::FS_XFS ) ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mkfs.xfs -f " + new_partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command( "mkfs.xfs -f " + new_partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
@ -131,9 +131,9 @@ bool xfs::Resize( const Partition & partition_new,
|
|||
|
||||
//mount partition
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( String::ucompose( _("mount %1 on %2"), partition_new .partition, TEMP_MP ) ) ) ;
|
||||
OperationDetails( String::ucompose( _("mount %1 on %2"), partition_new .get_path(), TEMP_MP ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "mount -v -t xfs " + partition_new .partition + " " + TEMP_MP,
|
||||
if ( ! execute_command( "mount -v -t xfs " + partition_new .get_path() + " " + TEMP_MP,
|
||||
operation_details .back() .sub_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
@ -154,9 +154,9 @@ bool xfs::Resize( const Partition & partition_new,
|
|||
|
||||
//and unmount it...
|
||||
operation_details .back() .sub_details .push_back(
|
||||
OperationDetails( String::ucompose( _("unmount %1"), partition_new .partition ) ) ) ;
|
||||
OperationDetails( String::ucompose( _("unmount %1"), partition_new .get_path() ) ) ) ;
|
||||
|
||||
if ( ! execute_command( "umount -v " + partition_new .partition,
|
||||
if ( ! execute_command( "umount -v " + partition_new .get_path(),
|
||||
operation_details .back() .sub_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
@ -212,8 +212,7 @@ bool xfs::Copy( const Glib::ustring & src_part_path,
|
|||
Glib::ustring DST = Glib::get_tmp_dir() + "/gparted_tmp_xfs_dest_mountpoint" ;
|
||||
|
||||
//create xfs filesystem on destination..
|
||||
Partition partition ;
|
||||
partition .partition = dest_part_path ;
|
||||
Partition partition( dest_part_path ) ;
|
||||
if ( Create( partition, operation_details .back() .sub_details ) )
|
||||
{
|
||||
//create source mountpoint...
|
||||
|
@ -358,7 +357,7 @@ bool xfs::Check_Repair( const Partition & partition, std::vector<OperationDetail
|
|||
{
|
||||
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
|
||||
|
||||
if ( ! execute_command ( "xfs_repair -v " + partition .partition, operation_details .back() .sub_details ) )
|
||||
if ( ! execute_command ( "xfs_repair -v " + partition .get_path(), operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
|
Loading…
Reference in New Issue