2004-11-17 06:00:25 -07:00
|
|
|
/* Copyright (C) 2004 Bart
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef FILESYSTEM
|
|
|
|
#define FILESYSTEM
|
|
|
|
|
|
|
|
#include "../include/Partition.h"
|
|
|
|
|
|
|
|
#include <gtkmm/textbuffer.h>
|
|
|
|
|
|
|
|
#include <parted/parted.h>
|
2004-12-14 15:49:44 -07:00
|
|
|
#include <fstream>
|
2004-11-17 06:00:25 -07:00
|
|
|
|
|
|
|
//Some functions used by both (sub)Filesystems and GParted_Core-------------------------------------------------
|
|
|
|
inline bool open_device( const Glib::ustring & device_path, PedDevice *& device )
|
|
|
|
{
|
|
|
|
device = ped_device_get( device_path .c_str( ) );
|
|
|
|
|
|
|
|
return device ;
|
|
|
|
}
|
|
|
|
|
2004-11-27 16:31:19 -07:00
|
|
|
inline bool open_device_and_disk( const Glib::ustring & device_path, PedDevice *& device, PedDisk *& disk, bool strict = true )
|
2004-11-17 06:00:25 -07:00
|
|
|
{
|
|
|
|
if ( open_device( device_path, device ) )
|
|
|
|
disk = ped_disk_new( device );
|
2004-11-27 16:31:19 -07:00
|
|
|
|
|
|
|
//if ! disk and writeable it's probably a HD without disklabel. We return true here and deal with them in GParted_Core::get_devices
|
|
|
|
if ( ! disk && ( strict || device ->read_only ) )
|
2004-11-17 06:00:25 -07:00
|
|
|
{
|
|
|
|
ped_device_destroy( device ) ;
|
|
|
|
device = NULL ;
|
|
|
|
|
|
|
|
return false;
|
2004-11-27 16:31:19 -07:00
|
|
|
}
|
|
|
|
|
2004-11-17 06:00:25 -07:00
|
|
|
return true ;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void close_device_and_disk( PedDevice *& device, PedDisk *& disk )
|
|
|
|
{
|
|
|
|
if ( device )
|
|
|
|
ped_device_destroy( device ) ;
|
|
|
|
|
|
|
|
if ( disk )
|
|
|
|
ped_disk_destroy( disk ) ;
|
|
|
|
|
|
|
|
device = NULL ;
|
|
|
|
disk = NULL ;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Commit( PedDisk *& disk )
|
|
|
|
{
|
|
|
|
bool return_value = ped_disk_commit_to_dev( disk ) ;
|
|
|
|
|
|
|
|
ped_disk_commit_to_os( disk ) ;
|
|
|
|
|
|
|
|
return return_value ;
|
|
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
|
|
|
class FileSystem
|
|
|
|
{
|
|
|
|
public:
|
2004-11-21 14:49:38 -07:00
|
|
|
FileSystem( ) ;
|
2004-11-17 06:00:25 -07:00
|
|
|
virtual ~FileSystem( ) { }
|
|
|
|
|
|
|
|
virtual FS get_filesystem_support( ) = 0 ;
|
2004-11-21 14:49:38 -07:00
|
|
|
virtual void Set_Used_Sectors( Partition & partition ) = 0 ;
|
2004-11-17 06:00:25 -07:00
|
|
|
virtual bool Create( const Glib::ustring device_path, const Partition & new_partition ) = 0 ;
|
2004-11-21 14:49:38 -07:00
|
|
|
virtual bool Resize( const Partition & partition_new, bool fill_partition = false ) = 0 ;
|
2004-11-17 06:00:25 -07:00
|
|
|
virtual bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) = 0 ;
|
2004-11-21 14:49:38 -07:00
|
|
|
virtual bool Check_Repair( const Partition & partition ) = 0 ;
|
2004-11-17 06:00:25 -07:00
|
|
|
virtual int get_estimated_time( long MB_to_Consider ) = 0 ;
|
2004-11-21 14:49:38 -07:00
|
|
|
|
2004-11-17 06:00:25 -07:00
|
|
|
Glib::RefPtr<Gtk::TextBuffer> textbuffer ;
|
|
|
|
|
2004-11-21 14:49:38 -07:00
|
|
|
PedDisk *disk ; //see GParted_Core::Set_Used_Sectors() ...
|
|
|
|
long cylinder_size ; //see GParted_Core::Resize()
|
|
|
|
|
2004-11-17 06:00:25 -07:00
|
|
|
protected:
|
2004-11-30 14:05:48 -07:00
|
|
|
int Execute_Command( Glib::ustring command ) ;
|
2004-11-17 06:00:25 -07:00
|
|
|
|
|
|
|
PedDevice *device ;
|
2004-11-17 07:12:18 -07:00
|
|
|
|
2004-11-17 06:00:25 -07:00
|
|
|
private:
|
|
|
|
void Update_Textview( ) ;
|
|
|
|
|
|
|
|
Glib::ustring output ;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} //GParted
|
|
|
|
|
|
|
|
#endif //FILESYSTEM
|