2009-11-05 11:08:32 -07:00
|
|
|
/* Copyright (C) 2004 Bart
|
2010-04-19 19:22:31 -06:00
|
|
|
* Copyright (C) 2008, 2009, 2010 Curtis Gedak
|
2004-09-19 14:24:53 -06:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* READ THIS!!
|
2004-10-02 13:30:20 -06:00
|
|
|
* Partition isn't really a partition. It's more like a geometry, a continuous part of the disk.
|
|
|
|
* I use it to represent partitions as well as unallocated spaces
|
2004-09-19 14:24:53 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PARTITION
|
|
|
|
#define PARTITION
|
|
|
|
|
2004-10-06 09:32:40 -06:00
|
|
|
#include "../include/Utils.h"
|
2004-09-20 09:46:21 -06:00
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
2005-12-07 04:21:27 -07:00
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
enum PartitionType {
|
2005-12-07 04:21:27 -07:00
|
|
|
TYPE_PRIMARY = 0,
|
|
|
|
TYPE_LOGICAL = 1,
|
|
|
|
TYPE_EXTENDED = 2,
|
|
|
|
TYPE_UNALLOCATED = 3
|
2004-09-19 14:24:53 -06:00
|
|
|
};
|
|
|
|
|
2004-09-25 08:12:07 -06:00
|
|
|
enum PartitionStatus {
|
2006-03-18 14:38:19 -07:00
|
|
|
STAT_REAL = 0,
|
|
|
|
STAT_NEW = 1,
|
|
|
|
STAT_COPY = 2,
|
|
|
|
STAT_FORMATTED = 3
|
2004-09-25 08:12:07 -06:00
|
|
|
};
|
|
|
|
|
2010-05-09 14:45:26 -06:00
|
|
|
enum PartitionAlignment {
|
|
|
|
ALIGN_CYLINDER = 0, //Align to nearest cylinder
|
2010-05-20 10:00:14 -06:00
|
|
|
ALIGN_MEBIBYTE = 1, //Align to nearest mebibyte
|
|
|
|
ALIGN_STRICT = 2 //Strict alignment - no rounding
|
2010-05-09 14:45:26 -06:00
|
|
|
// Indicator if start and end sectors must remain unchanged
|
|
|
|
};
|
|
|
|
|
2008-11-18 16:58:17 -07:00
|
|
|
//FIXME: we should make a difference between partition- and file system size.
|
2006-07-18 15:10:10 -06:00
|
|
|
//especially in the core this can make a difference when giving detailed feedback. With new cairosupport in gtkmm
|
|
|
|
//it's even possible to make stuff like this visible in the GUI in a nice and clear way
|
2004-09-19 14:24:53 -06:00
|
|
|
class Partition
|
|
|
|
{
|
|
|
|
public:
|
2005-12-23 17:06:05 -07:00
|
|
|
Partition() ;
|
2006-03-14 14:37:47 -07:00
|
|
|
Partition( const Glib::ustring & path ) ;
|
2005-12-23 17:06:05 -07:00
|
|
|
~Partition() ;
|
2004-10-11 04:23:24 -06:00
|
|
|
|
2005-12-23 17:06:05 -07:00
|
|
|
void Reset() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//simple Set-functions. only for convenience, since most members are public
|
2005-12-07 15:44:40 -07:00
|
|
|
void Set( const Glib::ustring & device_path,
|
|
|
|
const Glib::ustring & partition,
|
2005-12-23 17:06:05 -07:00
|
|
|
int partition_number,
|
|
|
|
PartitionType type,
|
|
|
|
FILESYSTEM filesystem,
|
|
|
|
Sector sector_start,
|
|
|
|
Sector sector_end,
|
2010-04-19 19:22:31 -06:00
|
|
|
Byte_Value sector_size,
|
2005-12-23 17:06:05 -07:00
|
|
|
bool inside_extended,
|
|
|
|
bool busy ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2004-11-21 14:49:38 -07:00
|
|
|
void Set_Unused( Sector sectors_unused ) ;
|
2006-03-29 12:21:42 -07:00
|
|
|
void set_used( Sector sectors_used ) ;
|
2004-10-11 04:23:24 -06:00
|
|
|
|
2006-03-14 14:37:47 -07:00
|
|
|
void Set_Unallocated( const Glib::ustring & device_path,
|
|
|
|
Sector sector_start,
|
|
|
|
Sector sector_end,
|
2010-04-19 19:22:31 -06:00
|
|
|
Byte_Value sector_size,
|
2006-03-14 14:37:47 -07:00
|
|
|
bool inside_extended );
|
2004-10-11 04:23:24 -06:00
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
//update partition number (used when a logical partition is deleted)
|
|
|
|
void Update_Number( int new_number );
|
|
|
|
|
2006-03-14 14:37:47 -07:00
|
|
|
void add_path( const Glib::ustring & path, bool clear_paths = false ) ;
|
|
|
|
void add_paths( const std::vector<Glib::ustring> & paths, bool clear_paths = false ) ;
|
2010-04-27 11:28:36 -06:00
|
|
|
Byte_Value get_byte_length() const ;
|
2010-04-28 09:11:44 -06:00
|
|
|
Sector get_sector_length() const ;
|
2006-03-14 14:37:47 -07:00
|
|
|
Glib::ustring get_path() const ;
|
|
|
|
std::vector<Glib::ustring> get_paths() const ;
|
2011-12-16 14:32:54 -07:00
|
|
|
void add_mountpoint( const Glib::ustring & mountpoint, bool clear_mountpoints = false ) ;
|
2006-03-15 09:12:11 -07:00
|
|
|
void add_mountpoints( const std::vector<Glib::ustring> & mountpoints, bool clear_mountpoints = false ) ;
|
|
|
|
Glib::ustring get_mountpoint() const ;
|
fixed issues with copying (see also #335004) cleanups + added FIXME added
* include/GParted_Core.h,
src/GParted_Core.cc,
src/Win_GParted.cc,
src/ext2.cc,
src/ext3.cc,
src/fat16.cc,
src/fat32.cc,
src/jfs.cc,
src/ntfs.cc,
src/reiserfs.cc: fixed issues with copying (see also #335004)
* include/Operation.h,
src/Operation.cc: cleanups + added FIXME
* include/Partition.h,
src/Partition.cc: added clear_mountpoints()
* src/DrawingAreaVisualDisk.cc: added FIXME
2006-03-19 08:30:20 -07:00
|
|
|
void clear_mountpoints() ;
|
2006-03-15 09:12:11 -07:00
|
|
|
std::vector<Glib::ustring> get_mountpoints() const ;
|
2006-08-01 06:47:03 -06:00
|
|
|
Sector get_sector() const ;
|
2006-09-07 14:31:05 -06:00
|
|
|
bool test_overlap( const Partition & partition ) const ;
|
2005-12-22 15:20:55 -07:00
|
|
|
|
2005-12-23 17:06:05 -07:00
|
|
|
bool operator==( const Partition & partition ) const ;
|
2006-03-29 12:21:42 -07:00
|
|
|
bool operator!=( const Partition & partition ) const ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
//some public members
|
2005-12-07 15:44:40 -07:00
|
|
|
Glib::ustring device_path ;
|
2004-09-19 14:24:53 -06:00
|
|
|
int partition_number;
|
|
|
|
PartitionType type;// UNALLOCATED, PRIMARY, LOGICAL, etc...
|
2004-09-25 08:12:07 -06:00
|
|
|
PartitionStatus status; //STAT_REAL, STAT_NEW, etc..
|
2010-05-09 14:45:26 -06:00
|
|
|
PartitionAlignment alignment; //ALIGN_CYLINDER, ALIGN_STRICT, etc
|
2005-12-07 04:21:27 -07:00
|
|
|
FILESYSTEM filesystem ;
|
2006-09-12 14:34:33 -06:00
|
|
|
Glib::ustring label ;
|
2008-11-11 10:21:22 -07:00
|
|
|
Glib::ustring uuid ;
|
2004-09-19 14:24:53 -06:00
|
|
|
Sector sector_start;
|
|
|
|
Sector sector_end;
|
|
|
|
Sector sectors_used;
|
|
|
|
Sector sectors_unused;
|
|
|
|
Gdk::Color color;
|
2005-12-23 17:06:05 -07:00
|
|
|
bool inside_extended;
|
2004-09-19 14:24:53 -06:00
|
|
|
bool busy;
|
2006-07-30 09:13:41 -06:00
|
|
|
std::vector<Glib::ustring> messages ;
|
2006-02-17 16:20:28 -07:00
|
|
|
std::vector<Glib::ustring> flags ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2004-11-06 04:55:03 -07:00
|
|
|
std::vector<Partition> logicals ;
|
2006-01-07 08:04:42 -07:00
|
|
|
|
2009-02-16 12:37:27 -07:00
|
|
|
bool strict_start ; //Indicator if start sector must stay unchanged
|
2010-05-20 10:00:14 -06:00
|
|
|
Sector free_space_before ; //Free space preceding partition value
|
2010-04-19 19:06:08 -06:00
|
|
|
|
|
|
|
Byte_Value sector_size ; //Sector size of the disk device needed for converting to/from sectors and bytes.
|
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
private:
|
2006-03-14 14:37:47 -07:00
|
|
|
void sort_paths_and_remove_duplicates() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-03-14 14:37:47 -07:00
|
|
|
static bool compare_paths( const Glib::ustring & A, const Glib::ustring & B ) ;
|
|
|
|
|
|
|
|
std::vector<Glib::ustring> paths ;
|
2006-03-15 09:12:11 -07:00
|
|
|
std::vector<Glib::ustring> mountpoints ;
|
2004-09-19 14:24:53 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
}//GParted
|
|
|
|
#endif //PARTITION
|