2004-10-06 09:32:40 -06: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* UTILS
|
|
|
|
* Some stuff i need in a lot of places so i dropped in all together in one file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UTILS
|
|
|
|
#define UTILS
|
|
|
|
|
2005-12-07 04:21:27 -07:00
|
|
|
#include "../include/i18n.h"
|
|
|
|
|
2004-10-06 09:32:40 -06:00
|
|
|
#include <gtkmm/label.h>
|
|
|
|
#include <glibmm/ustring.h>
|
|
|
|
|
2005-12-13 14:30:13 -07:00
|
|
|
#include <iostream>
|
2004-10-06 09:32:40 -06:00
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
|
|
|
typedef long long Sector;
|
|
|
|
|
2006-01-21 17:07:27 -07:00
|
|
|
//sizeunits defined in sectors of 512 bytes..
|
|
|
|
#define KIBIBYTE 2
|
|
|
|
#define MEBIBYTE 2048
|
|
|
|
#define GIBIBYTE 2097152
|
|
|
|
#define TEBIBYTE 2147483648U
|
2004-10-06 09:32:40 -06:00
|
|
|
|
2005-12-07 04:21:27 -07:00
|
|
|
enum FILESYSTEM
|
|
|
|
{
|
|
|
|
FS_UNALLOCATED = 0,
|
|
|
|
FS_UNKNOWN = 1,
|
|
|
|
FS_UNFORMATTED = 2,
|
|
|
|
FS_EXTENDED = 3,
|
2005-12-15 08:10:34 -07:00
|
|
|
|
2005-12-07 04:21:27 -07:00
|
|
|
FS_EXT2 = 4,
|
|
|
|
FS_EXT3 = 5,
|
|
|
|
FS_LINUX_SWAP = 6,
|
|
|
|
FS_FAT16 = 7,
|
|
|
|
FS_FAT32 = 8,
|
|
|
|
FS_NTFS = 9,
|
|
|
|
FS_REISERFS = 10,
|
|
|
|
FS_REISER4 = 11,
|
|
|
|
FS_XFS = 12,
|
|
|
|
FS_JFS = 13,
|
|
|
|
FS_HFS = 14,
|
|
|
|
FS_HFSPLUS = 15,
|
2005-12-15 08:10:34 -07:00
|
|
|
FS_UFS = 16,
|
|
|
|
|
|
|
|
FS_USED = 17,
|
|
|
|
FS_UNUSED = 18
|
2006-03-31 03:49:27 -07:00
|
|
|
} ;
|
2004-10-06 09:32:40 -06:00
|
|
|
|
2006-01-21 17:07:27 -07:00
|
|
|
enum SIZE_UNIT
|
|
|
|
{
|
|
|
|
UNIT_SECTOR = 0,
|
|
|
|
UNIT_BYTE = 1,
|
|
|
|
|
|
|
|
UNIT_KIB = 2,
|
|
|
|
UNIT_MIB = 3,
|
|
|
|
UNIT_GIB = 4,
|
2006-03-31 03:49:27 -07:00
|
|
|
UNIT_TIB = 5
|
|
|
|
} ;
|
2006-01-21 17:07:27 -07:00
|
|
|
|
2005-12-07 04:21:27 -07:00
|
|
|
//struct to store filesysteminformation
|
2004-10-06 09:32:40 -06:00
|
|
|
struct FS
|
|
|
|
{
|
2005-11-26 17:57:11 -07:00
|
|
|
enum Support
|
|
|
|
{
|
|
|
|
NONE = 0,
|
|
|
|
LIBPARTED = 1,
|
|
|
|
EXTERNAL = 2
|
|
|
|
};
|
|
|
|
|
2005-12-07 04:21:27 -07:00
|
|
|
FILESYSTEM filesystem ;
|
2005-11-26 17:57:11 -07:00
|
|
|
Support read ; //can we get the amount of used sectors?
|
|
|
|
Support create ;
|
|
|
|
Support grow ;
|
|
|
|
Support shrink ;
|
|
|
|
Support move ; //startpoint and endpoint
|
|
|
|
Support check ; //some checktool available?
|
|
|
|
Support copy ;
|
2006-02-17 14:18:07 -07:00
|
|
|
|
2006-02-25 03:09:30 -07:00
|
|
|
Sector MIN ;
|
|
|
|
Sector MAX ;
|
2004-11-17 06:00:25 -07:00
|
|
|
|
2006-01-21 17:07:27 -07:00
|
|
|
FS()
|
2004-12-09 15:56:33 -07:00
|
|
|
{
|
2005-11-26 17:57:11 -07:00
|
|
|
read = create = grow = shrink = move = check = copy = NONE;
|
2005-08-30 20:30:25 -06:00
|
|
|
MIN = MAX = 0 ;
|
2004-12-09 15:56:33 -07:00
|
|
|
}
|
2006-03-31 03:49:27 -07:00
|
|
|
} ;
|
2004-11-17 06:00:25 -07:00
|
|
|
|
2004-10-06 09:32:40 -06:00
|
|
|
|
2005-12-13 14:30:13 -07:00
|
|
|
class Utils
|
2004-10-06 09:32:40 -06:00
|
|
|
{
|
2005-12-13 14:30:13 -07:00
|
|
|
public:
|
2006-03-28 05:40:29 -07:00
|
|
|
static Sector round( double double_value ) ;
|
2005-12-14 07:47:58 -07:00
|
|
|
static Gtk::Label * mk_label( const Glib::ustring & text,
|
|
|
|
bool use_markup = true,
|
2006-03-28 05:40:29 -07:00
|
|
|
Gtk::AlignmentEnum x_align = Gtk::ALIGN_LEFT,
|
|
|
|
Gtk::AlignmentEnum y_align = Gtk::ALIGN_CENTER,
|
2005-12-14 07:47:58 -07:00
|
|
|
bool wrap = false,
|
|
|
|
const Glib::ustring & text_color = "black" ) ;
|
2005-12-13 14:30:13 -07:00
|
|
|
static Glib::ustring num_to_str( Sector number, bool use_C_locale = false ) ;
|
2006-03-28 05:40:29 -07:00
|
|
|
static Glib::ustring get_color( FILESYSTEM filesystem ) ;
|
2005-12-15 08:10:34 -07:00
|
|
|
static Glib::RefPtr<Gdk::Pixbuf> get_color_as_pixbuf( FILESYSTEM filesystem, int width, int height ) ;
|
2006-03-28 05:40:29 -07:00
|
|
|
static Glib::ustring get_filesystem_string( FILESYSTEM filesystem ) ;
|
2006-01-04 11:54:46 -07:00
|
|
|
static Glib::ustring format_size( Sector size ) ;
|
2006-01-21 17:07:27 -07:00
|
|
|
static double sector_to_unit( Sector sectors, SIZE_UNIT size_unit ) ;
|
2006-04-02 07:04:24 -06:00
|
|
|
static int execute_command( const Glib::ustring & command ) ;
|
2006-02-15 09:05:26 -07:00
|
|
|
static int execute_command( const Glib::ustring & command,
|
|
|
|
Glib::ustring & output,
|
|
|
|
Glib::ustring & error,
|
|
|
|
bool use_C_locale = false ) ;
|
2005-12-13 14:30:13 -07:00
|
|
|
};
|
2004-10-07 08:12:34 -06:00
|
|
|
|
2004-10-06 09:32:40 -06:00
|
|
|
|
|
|
|
}//GParted
|
|
|
|
|
|
|
|
#endif //UTILS
|