Made Partition::mountpoints private
* include/Partition.h, src/Dialog_Partition_Info.cc, src/GParted_Core.cc, src/Partition.cc, src/TreeView_Detail.cc, src/Win_GParted.cc: Made Partition::mountpoints private
This commit is contained in:
parent
6d8b169e73
commit
9532c3cad1
|
@ -1,3 +1,12 @@
|
|||
2006-03-15 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Partition.h,
|
||||
src/Dialog_Partition_Info.cc,
|
||||
src/GParted_Core.cc,
|
||||
src/Partition.cc,
|
||||
src/TreeView_Detail.cc,
|
||||
src/Win_GParted.cc: Made Partition::mountpoints private
|
||||
|
||||
2006-03-14 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* changed the way devices and partitions store their devicepaths.
|
||||
|
|
|
@ -78,6 +78,9 @@ public:
|
|||
Sector get_length() const ;
|
||||
Glib::ustring get_path() const ;
|
||||
std::vector<Glib::ustring> get_paths() const ;
|
||||
void add_mountpoints( const std::vector<Glib::ustring> & mountpoints, bool clear_mountpoints = false ) ;
|
||||
Glib::ustring get_mountpoint() const ;
|
||||
std::vector<Glib::ustring> get_mountpoints() const ;
|
||||
|
||||
bool operator==( const Partition & partition ) const ;
|
||||
|
||||
|
@ -96,8 +99,6 @@ public:
|
|||
bool busy;
|
||||
Glib::ustring error;
|
||||
std::vector<Glib::ustring> flags ;
|
||||
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 ;
|
||||
|
||||
|
@ -109,6 +110,7 @@ private:
|
|||
static bool compare_paths( const Glib::ustring & A, const Glib::ustring & B ) ;
|
||||
|
||||
std::vector<Glib::ustring> paths ;
|
||||
std::vector<Glib::ustring> mountpoints ;
|
||||
};
|
||||
|
||||
}//GParted
|
||||
|
|
|
@ -195,9 +195,9 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
str_temp = _("Busy (At least one logical partition is mounted)" ) ;
|
||||
else if ( partition .filesystem == FS_LINUX_SWAP )
|
||||
str_temp = _("Active") ;
|
||||
else if ( partition .mountpoints .size() )
|
||||
else if ( partition .get_mountpoints() .size() )
|
||||
str_temp = String::ucompose( _("Mounted on %1"),
|
||||
Glib::build_path( ", ", partition .mountpoints ) ) ;
|
||||
Glib::build_path( ", ", partition .get_mountpoints() ) ) ;
|
||||
}
|
||||
else if ( partition.type == GParted::TYPE_EXTENDED )
|
||||
str_temp = _("Not busy (There are no mounted logical partitions)" ) ;
|
||||
|
|
|
@ -405,19 +405,19 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
|
|||
iter_mp = mount_info .find( partitions[ t ] .get_paths()[ i ] ) ;
|
||||
if ( iter_mp != mount_info .end() )
|
||||
{
|
||||
partitions[ t ] .mountpoints = iter_mp ->second ;
|
||||
partitions[ t ] .add_mountpoints( iter_mp ->second ) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( partitions[ t ] .mountpoints .empty() )
|
||||
if ( partitions[ t ] .get_mountpoints() .empty() )
|
||||
partitions[ t ] .error = _("Unable to find mountpoint") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
iter_mp = fstab_info .find( partitions[ t ] .get_path() );
|
||||
if ( iter_mp != fstab_info .end() )
|
||||
partitions[ t ] .mountpoints = iter_mp ->second ;
|
||||
partitions[ t ] .add_mountpoints( iter_mp ->second ) ;
|
||||
}
|
||||
}
|
||||
else if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
|
||||
|
@ -456,13 +456,13 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
|
|||
{
|
||||
if ( partitions[ t ] .busy )
|
||||
{
|
||||
if ( partitions[ t ] .mountpoints .size() > 0 )
|
||||
if ( partitions[ t ] .get_mountpoints() .size() > 0 )
|
||||
{
|
||||
if ( statvfs( partitions[ t ] .mountpoints .front() .c_str(), &sfs ) == 0 )
|
||||
if ( statvfs( partitions[ t ] .get_mountpoint() .c_str(), &sfs ) == 0 )
|
||||
partitions[ t ] .Set_Unused( sfs .f_bfree * (sfs .f_bsize / 512) ) ;
|
||||
else
|
||||
partitions[ t ] .error =
|
||||
"statvfs (" + partitions[ t ] .mountpoints .front() + "): " + Glib::strerror( errno );
|
||||
"statvfs (" + partitions[ t ] .get_mountpoint() + "): " + Glib::strerror( errno );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -172,6 +172,27 @@ void Partition::sort_paths_and_remove_duplicates()
|
|||
std::sort( paths .begin(), paths .end(), compare_paths ) ;
|
||||
}
|
||||
|
||||
void Partition::add_mountpoints( const std::vector<Glib::ustring> & mountpoints, bool clear_mountpoints )
|
||||
{
|
||||
if ( clear_mountpoints )
|
||||
this ->mountpoints .clear() ;
|
||||
|
||||
this ->mountpoints .insert( this ->mountpoints .end(), mountpoints .begin(), mountpoints .end() ) ;
|
||||
}
|
||||
|
||||
Glib::ustring Partition::get_mountpoint() const
|
||||
{
|
||||
if ( mountpoints .size() > 0 )
|
||||
return mountpoints .front() ;
|
||||
|
||||
return "" ;
|
||||
}
|
||||
|
||||
std::vector<Glib::ustring> Partition::get_mountpoints() const
|
||||
{
|
||||
return mountpoints ;
|
||||
}
|
||||
|
||||
bool Partition::compare_paths( const Glib::ustring & A, const Glib::ustring & B )
|
||||
{
|
||||
return A .length() < B .length() ;
|
||||
|
|
|
@ -99,12 +99,12 @@ void TreeView_Detail::load_partitions( const std::vector<Partition> & partitions
|
|||
childrow = *( treestore_detail ->append( row.children() ) );
|
||||
create_row( childrow, partitions[ i ] .logicals[ t ] );
|
||||
|
||||
if ( partitions[ i ] .logicals[ t ] .mountpoints .size() )
|
||||
if ( partitions[ i ] .logicals[ t ] .get_mountpoints() .size() )
|
||||
mount_info = true ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( partitions[ i ] .mountpoints .size() )
|
||||
if ( partitions[ i ] .get_mountpoints() .size() )
|
||||
mount_info = true ;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition
|
|||
|
||||
//mountpoint
|
||||
treerow[ treeview_detail_columns .mount_text_color ] = partition .busy ? "black" : "darkgrey" ;
|
||||
treerow[ treeview_detail_columns .mountpoint ] = Glib::build_path( ", ", partition .mountpoints ) ;
|
||||
treerow[ treeview_detail_columns .mountpoint ] = Glib::build_path( ", ", partition .get_mountpoints() ) ;
|
||||
|
||||
//size
|
||||
treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_length() ) ;
|
||||
|
|
|
@ -756,7 +756,7 @@ void Win_GParted::set_valid_operations()
|
|||
if ( selected_partition .status == GParted::STAT_REAL && fs .copy )
|
||||
allow_copy( true ) ;
|
||||
|
||||
if ( selected_partition .mountpoints .size() )
|
||||
if ( selected_partition .get_mountpoints() .size() )
|
||||
{
|
||||
allow_toggle_swap_mount_state( true ) ;
|
||||
|
||||
|
@ -1372,10 +1372,12 @@ void Win_GParted::thread_unmount_partition( bool * succes, Glib::ustring * error
|
|||
Glib::ustring dummy ;
|
||||
|
||||
*succes = true ;
|
||||
for ( unsigned int t = 0 ; t < selected_partition .mountpoints .size() ; t++ )
|
||||
if ( std::count( mountpoints .begin(), mountpoints .end(), selected_partition .mountpoints[ t ] ) <= 1 )
|
||||
for ( unsigned int t = 0 ; t < selected_partition .get_mountpoints() .size() ; t++ )
|
||||
if ( std::count( mountpoints .begin(),
|
||||
mountpoints .end(),
|
||||
selected_partition .get_mountpoints()[ t ] ) <= 1 )
|
||||
{
|
||||
if ( Utils::execute_command( "umount -v " + selected_partition .mountpoints[ t ],
|
||||
if ( Utils::execute_command( "umount -v " + selected_partition .get_mountpoints()[ t ],
|
||||
dummy,
|
||||
*error ) )
|
||||
{
|
||||
|
@ -1384,7 +1386,7 @@ void Win_GParted::thread_unmount_partition( bool * succes, Glib::ustring * error
|
|||
}
|
||||
}
|
||||
else
|
||||
failed_mountpoints .push_back( selected_partition .mountpoints[ t ] ) ;
|
||||
failed_mountpoints .push_back( selected_partition .get_mountpoints()[ t ] ) ;
|
||||
|
||||
|
||||
if ( *succes && failed_mountpoints .size() )
|
||||
|
@ -1406,8 +1408,9 @@ void Win_GParted::thread_mount_partition( bool * succes, Glib::ustring * error )
|
|||
std::vector<Glib::ustring> errors ;
|
||||
|
||||
*succes = true ;
|
||||
for ( unsigned int t = 0 ; t < selected_partition .mountpoints .size() ; t++ )
|
||||
if ( Utils::execute_command( "mount -v " + selected_partition .get_path() + " " + selected_partition .mountpoints[ t ],
|
||||
for ( unsigned int t = 0 ; t < selected_partition .get_mountpoints() .size() ; t++ )
|
||||
if ( Utils::execute_command(
|
||||
"mount -v " + selected_partition .get_path() + " " + selected_partition .get_mountpoints()[ t ],
|
||||
dummy,
|
||||
*error ) )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue