gparted r810 - in trunk: . include po src
- From: gedakc svn gnome org
- To: svn-commits-list gnome org
- Subject: gparted r810 - in trunk: . include po src
- Date: Mon, 7 Apr 2008 20:41:19 +0100 (BST)
Author: gedakc
Date: Mon Apr 7 20:41:18 2008
New Revision: 810
URL: http://svn.gnome.org/viewvc/gparted?rev=810&view=rev
Log:
gparted-0.3.6 - code recreation from Source Forge
Added:
trunk/include/Dialog_Partition_Label.h
trunk/include/OperationLabelPartition.h
trunk/src/Dialog_Partition_Label.cc
trunk/src/OperationLabelPartition.cc
Modified:
trunk/AUTHORS
trunk/ChangeLog
trunk/Makefile.am
trunk/configure.in
trunk/include/DialogFeatures.h
trunk/include/Dialog_Partition_New.h
trunk/include/FileSystem.h
trunk/include/GParted_Core.h
trunk/include/Makefile.am
trunk/include/Operation.h
trunk/include/Utils.h
trunk/include/Win_GParted.h
trunk/include/ext2.h
trunk/include/ext3.h
trunk/include/fat16.h
trunk/include/fat32.h
trunk/include/hfs.h
trunk/include/hfsplus.h
trunk/include/jfs.h
trunk/include/linux_swap.h
trunk/include/ntfs.h
trunk/include/reiser4.h
trunk/include/reiserfs.h
trunk/include/ufs.h
trunk/include/xfs.h
trunk/po/ChangeLog
trunk/po/POTFILES.in
trunk/src/DialogFeatures.cc
trunk/src/Dialog_Partition_Info.cc
trunk/src/Dialog_Partition_New.cc
trunk/src/Dialog_Progress.cc
trunk/src/GParted_Core.cc
trunk/src/Makefile.am
trunk/src/Utils.cc
trunk/src/Win_GParted.cc
trunk/src/ext2.cc
trunk/src/ext3.cc
trunk/src/fat16.cc
trunk/src/fat32.cc
trunk/src/hfs.cc
trunk/src/hfsplus.cc
trunk/src/jfs.cc
trunk/src/linux_swap.cc
trunk/src/ntfs.cc
trunk/src/reiser4.cc
trunk/src/reiserfs.cc
trunk/src/ufs.cc
trunk/src/xfs.cc
Modified: trunk/AUTHORS
==============================================================================
--- trunk/AUTHORS (original)
+++ trunk/AUTHORS Mon Apr 7 20:41:18 2008
@@ -1,3 +1,24 @@
-Bart
-email: gparted users sourceforge net
-IRC : irc.gnome.org #gparted
+This file is part of GParted
+Copyright (C) 2004, 2005, 2006, 2007, 2008
+ Bart Hakvoort
+Portions Copyright (C) 2008
+ Curtis Gedak
+
+This file may be modified and/or distributed without restriction. This is
+not an invitation to misrepresent who contributed to GNU GParted.
+
+-------------------------------------------------------------------------------
+
+We need to keep track of copyright (see the Maintainer HOWTO on www.gnu.org).
+
+Curtis Gedak <gedakc users sourceforge net>
+ * Wrote get_label functionality for fat16 and fat32 filesystems
+ * Wrote Utils::regexp_label() function
+ * Wrote set partition label functionality
+ * Created Dialog_Partion_Label.h, Dialog_Partition_Label.cc
+ * Created OperationLabelPartition.h, OperationLabelPartition.cc
+
+Bart Harkvoort <gparted users sourceforge net>
+ * Original author of GParted.
+ * Created and maintained up to official 0.3.3 release and
+ the unofficial 0.3.4 release.
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Mon Apr 7 20:41:18 2008
@@ -19,4 +19,9 @@
intltool-extract \
intltool-merge \
intltool-update \
- $(desktop_DATA)
+ $(desktop_DATA)
+
+distclean-local:
+ rm -rf autom4te.cache
+ find . -name .svn | xargs rm -rf
+ find . -name .cvsignore | xargs rm -rf
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-AC_INIT(gparted, 0.3.5)
+AC_INIT(gparted, 0.3.6)
AC_CONFIG_SRCDIR(src/main.cc)
AM_INIT_AUTOMAKE
@@ -20,7 +20,7 @@
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",[description])
-ALL_LINGUAS="ar bg ca cs de dz el en_CA en_GB es eu fi fr gl he hu it ja lt lv mk nb ne nl oc pa pl pt pt_BR ru rw sl sv th tr uk vi zh_CN zh_HK zh_TW"
+ALL_LINGUAS="ar bg ca cs de dz el en_CA en_GB es eu fi fr gl he hu it ja ko lt lv mk nb ne nl oc pa pl pt pt_BR ru rw si sk sl sv th tr uk vi zh_CN zh_HK zh_TW"
AM_GLIB_GNU_GETTEXT
AC_PROG_INTLTOOL
Modified: trunk/include/DialogFeatures.h
==============================================================================
--- trunk/include/DialogFeatures.h (original)
+++ trunk/include/DialogFeatures.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2006 Bart 'plors' Hakvoort
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -56,7 +56,7 @@
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > move ;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > copy ;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > check ;
- Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > read_label ;
+ Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > label ;
treeview_filesystems_Columns()
{
@@ -69,7 +69,7 @@
add( move ) ;
add( copy ) ;
add( check ) ;
- add( read_label ) ;
+ add( label ) ;
}
};
Added: trunk/include/Dialog_Partition_Label.h
==============================================================================
--- (empty file)
+++ trunk/include/Dialog_Partition_Label.h Mon Apr 7 20:41:18 2008
@@ -0,0 +1,55 @@
+/* Copyright (C) 2008 Curtis Gedak
+ *
+ * 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 DIALOG_PARTITION_LABEL_H_
+#define DIALOG_PARTITION_LABEL_H_
+
+#include "../include/Partition.h"
+#include "../include/i18n.h"
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/stock.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/table.h>
+#include <gtkmm/entry.h>
+
+#define BORDER 8
+
+namespace GParted
+{
+
+class Dialog_Partition_Label : public Gtk::Dialog
+{
+public:
+ Dialog_Partition_Label( const Partition & partition );
+ ~Dialog_Partition_Label();
+ Glib::ustring get_new_label();
+
+private:
+ Partition partition ;
+
+ Gtk::HBox *hbox ;
+ Gtk::VBox *vbox ;
+ Gtk::Frame *frame;
+ Gtk::Image *image;
+ Gtk::Table *table;
+ Gtk::Entry *entry;
+};
+
+} //GParted
+
+#endif //DIALOG_PARTITION_LABEL_H_
Modified: trunk/include/Dialog_Partition_New.h
==============================================================================
--- trunk/include/Dialog_Partition_New.h (original)
+++ trunk/include/Dialog_Partition_New.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -45,6 +45,7 @@
Gtk::OptionMenu optionmenu_type, optionmenu_filesystem;
Gtk::CheckButton checkbutton_round_to_cylinders ;
Gtk::Menu menu_type, menu_filesystem;
+ Gtk::Entry entry;
std::vector<FS> FILESYSTEMS ;
int cylinder_size ;
Modified: trunk/include/FileSystem.h
==============================================================================
--- trunk/include/FileSystem.h (original)
+++ trunk/include/FileSystem.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -36,6 +36,7 @@
virtual FS get_filesystem_support() = 0 ;
virtual void set_used_sectors( Partition & partition ) = 0 ;
virtual void get_label( Partition & partition ) = 0 ;
+ virtual bool set_label( const Partition & partition, OperationDetail & operationdetail ) = 0 ;
virtual bool create( const Partition & new_partition, OperationDetail & operationdetail ) = 0 ;
virtual bool resize( const Partition & partition_new,
OperationDetail & operationdetail,
Modified: trunk/include/GParted_Core.h
==============================================================================
--- trunk/include/GParted_Core.h (original)
+++ trunk/include/GParted_Core.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -80,6 +80,8 @@
bool Delete( const Partition & partition, OperationDetail & operationdetail ) ;
+ bool label_partition( const Partition & partition, OperationDetail & operation_detail ) ;
+
bool resize_move( const Device & device,
const Partition & partition_old,
Partition & partition_new,
Modified: trunk/include/Makefile.am
==============================================================================
--- trunk/include/Makefile.am (original)
+++ trunk/include/Makefile.am Mon Apr 7 20:41:18 2008
@@ -5,7 +5,8 @@
Dialog_Base_Partition.h \
Dialog_Disklabel.h \
Dialog_Partition_Copy.h \
- Dialog_Partition_Info.h \
+ Dialog_Partition_Info.h \
+ Dialog_Partition_Label.h \
Dialog_Partition_New.h \
Dialog_Partition_Resize_Move.h \
Dialog_Progress.h \
@@ -25,6 +26,7 @@
OperationDetail.h \
OperationFormat.h \
OperationResizeMove.h \
+ OperationLabelPartition.h \
Partition.h \
TreeView_Detail.h \
Utils.h \
Modified: trunk/include/Operation.h
==============================================================================
--- trunk/include/Operation.h (original)
+++ trunk/include/Operation.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -25,12 +25,13 @@
{
//FIXME: stop using GParted:: in front of our own enums.. it's not necessary and clutters the code
enum OperationType {
- OPERATION_DELETE = 0,
+ OPERATION_DELETE = 0,
OPERATION_CHECK = 1,
OPERATION_CREATE = 2,
OPERATION_RESIZE_MOVE = 3,
OPERATION_FORMAT = 4,
- OPERATION_COPY = 5
+ OPERATION_COPY = 5,
+ OPERATION_LABEL_PARTITION = 6
};
class Operation
Added: trunk/include/OperationLabelPartition.h
==============================================================================
--- (empty file)
+++ trunk/include/OperationLabelPartition.h Mon Apr 7 20:41:18 2008
@@ -0,0 +1,41 @@
+/* Copyright (C) 2008 Curtis Gedak
+ *
+ * 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 OPERATIONLABELPARTITION_H_
+#define OPERATIONLABELPARTITION_H_
+
+#include "../include/Operation.h"
+
+namespace GParted
+{
+
+class OperationLabelPartition : public Operation
+{
+public:
+ OperationLabelPartition( const Device & device,
+ const Partition & partition_orig,
+ const Partition & partition_new ) ;
+
+void apply_to_visual( std::vector<Partition> & partitions ) ;
+
+private:
+ void create_description() ;
+} ;
+
+} //GParted
+
+#endif //OPERATIONLABELPARTITION_H_
Modified: trunk/include/Utils.h
==============================================================================
--- trunk/include/Utils.h (original)
+++ trunk/include/Utils.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -93,6 +93,7 @@
FILESYSTEM filesystem ;
Support read ; //can we get the amount of used sectors?
Support get_label ;
+ Support set_label ;
Support create ;
Support grow ;
Support shrink ;
@@ -105,7 +106,7 @@
FS()
{
- read = get_label = create = grow = shrink = move = check = copy = NONE;
+ read = get_label = set_label = create = grow = shrink = move = check = copy = NONE;
MIN = MAX = 0 ;
}
} ;
@@ -133,6 +134,13 @@
Glib::ustring & output,
Glib::ustring & error,
bool use_C_locale = false ) ;
+ static Glib::ustring regexp_label( const Glib::ustring & text,
+ const Glib::ustring & regular_sub_expression ) ;
+ static Glib::ustring create_mtoolsrc_file( char file_name[],
+ const char drive_letter, const Glib::ustring & device_path ) ;
+ static Glib::ustring delete_mtoolsrc_file( const char file_name[] ) ;
+ static Glib::ustring trim( const Glib::ustring & src, const Glib::ustring & c = " \t\r\n" ) ;
+
};
Modified: trunk/include/Win_GParted.h
==============================================================================
--- trunk/include/Win_GParted.h (original)
+++ trunk/include/Win_GParted.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -100,6 +100,9 @@
void allow_check( bool state ) {
toggle_item( state, MENU_CHECK ) ; }
+ void allow_label_partition( bool state ) {
+ toggle_item( state, MENU_LABEL_PARTITION ) ; }
+
void allow_info( bool state ) {
toggle_item( state, MENU_INFO ) ; }
@@ -158,6 +161,7 @@
void activate_disklabel() ;
void activate_manage_flags() ;
void activate_check() ;
+ void activate_label_partition() ;
void activate_undo();
void remove_operation( int index = -1, bool remove_all = false ) ;
@@ -222,7 +226,8 @@
MENU_TOGGLE_MOUNT_SWAP,
MENU_MOUNT,
MENU_FLAGS,
- MENU_CHECK,
+ MENU_CHECK,
+ MENU_LABEL_PARTITION,
MENU_INFO,
TOOLBAR_UNDO,
TOOLBAR_APPLY ;
Modified: trunk/include/ext2.h
==============================================================================
--- trunk/include/ext2.h (original)
+++ trunk/include/ext2.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/ext3.h
==============================================================================
--- trunk/include/ext3.h (original)
+++ trunk/include/ext3.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/fat16.h
==============================================================================
--- trunk/include/fat16.h (original)
+++ trunk/include/fat16.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/fat32.h
==============================================================================
--- trunk/include/fat32.h (original)
+++ trunk/include/fat32.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support();
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/hfs.h
==============================================================================
--- trunk/include/hfs.h (original)
+++ trunk/include/hfs.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/hfsplus.h
==============================================================================
--- trunk/include/hfsplus.h (original)
+++ trunk/include/hfsplus.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/jfs.h
==============================================================================
--- trunk/include/jfs.h (original)
+++ trunk/include/jfs.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/linux_swap.h
==============================================================================
--- trunk/include/linux_swap.h (original)
+++ trunk/include/linux_swap.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/ntfs.h
==============================================================================
--- trunk/include/ntfs.h (original)
+++ trunk/include/ntfs.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/reiser4.h
==============================================================================
--- trunk/include/reiser4.h (original)
+++ trunk/include/reiser4.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/reiserfs.h
==============================================================================
--- trunk/include/reiserfs.h (original)
+++ trunk/include/reiserfs.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/ufs.h
==============================================================================
--- trunk/include/ufs.h (original)
+++ trunk/include/ufs.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/include/xfs.h
==============================================================================
--- trunk/include/xfs.h (original)
+++ trunk/include/xfs.h Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -30,6 +30,7 @@
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void get_label( Partition & partition ) ;
+ bool set_label( const Partition & partition, OperationDetail & operationdetail ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Mon Apr 7 20:41:18 2008
@@ -5,6 +5,7 @@
src/Dialog_Disklabel.cc
src/Dialog_Partition_Copy.cc
src/Dialog_Partition_Info.cc
+src/Dialog_Partition_Label.cc
src/Dialog_Partition_New.cc
src/Dialog_Partition_Resize_Move.cc
src/Dialog_Progress.cc
@@ -17,6 +18,7 @@
src/OperationCreate.cc
src/OperationDelete.cc
src/OperationFormat.cc
+src/OperationLabelPartition.cc
src/OperationResizeMove.cc
src/Partition.cc
src/TreeView_Detail.cc
Modified: trunk/src/DialogFeatures.cc
==============================================================================
--- trunk/src/DialogFeatures.cc (original)
+++ trunk/src/DialogFeatures.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2006 Bart 'plors' Hakvoort
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -39,7 +39,7 @@
treeview_filesystems .append_column( _("Move"), treeview_filesystems_columns .move );
treeview_filesystems .append_column( _("Copy"), treeview_filesystems_columns .copy );
treeview_filesystems .append_column( _("Check"), treeview_filesystems_columns .check );
- treeview_filesystems .append_column( _("Read Label"), treeview_filesystems_columns .read_label );
+ treeview_filesystems .append_column( _("Label"), treeview_filesystems_columns .label );
//FIXME: add info about the relevant project (e.g an url to the projectpage)
//of course this url has to be selectable and (if possible) clickable
treeview_filesystems .get_selection() ->set_mode( Gtk::SELECTION_NONE );
@@ -93,7 +93,7 @@
treerow[ treeview_filesystems_columns .move ] = fs .move ? icon_yes : icon_no ;
treerow[ treeview_filesystems_columns .copy ] = fs .copy ? icon_yes : icon_no ;
treerow[ treeview_filesystems_columns .check ] = fs .check ? icon_yes : icon_no ;
- treerow[ treeview_filesystems_columns .read_label ] = fs .get_label ? icon_yes : icon_no ;
+ treerow[ treeview_filesystems_columns .label ] = fs .set_label ? icon_yes : icon_no ;
}
DialogFeatures::~DialogFeatures()
Modified: trunk/src/Dialog_Partition_Info.cc
==============================================================================
--- trunk/src/Dialog_Partition_Info.cc (original)
+++ trunk/src/Dialog_Partition_Info.cc Mon Apr 7 20:41:18 2008
@@ -156,7 +156,7 @@
1, 2,
top++, bottom++,
Gtk::FILL ) ;
-
+
//size
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Size:") ) + "</b>" ),
0, 1,
@@ -258,6 +258,19 @@
table ->attach( * Utils::mk_label( str_temp ), 1, 2, top++, bottom++, Gtk::FILL ) ;
}
+
+ //label
+ if ( partition.type != GParted::TYPE_UNALLOCATED && partition.type != GParted::TYPE_EXTENDED )
+ {
+ table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Label:") ) + "</b>"),
+ 0, 1,
+ top, bottom,
+ Gtk::FILL) ;
+ table ->attach( * Utils::mk_label( partition .label ),
+ 1, 2,
+ top++, bottom++,
+ Gtk::FILL) ;
+ }
//one blank line
table ->attach( * Utils::mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL ) ;
Added: trunk/src/Dialog_Partition_Label.cc
==============================================================================
--- (empty file)
+++ trunk/src/Dialog_Partition_Label.cc Mon Apr 7 20:41:18 2008
@@ -0,0 +1,75 @@
+/* Copyright (C) 2008 Curtis Gedak
+ *
+ * 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.
+ */
+
+#include "../include/Dialog_Partition_Label.h"
+
+namespace GParted
+{
+
+Dialog_Partition_Label::Dialog_Partition_Label( const Partition & partition )
+{
+ this ->partition = partition ;
+
+ this ->set_resizable( false ) ;
+ this ->set_has_separator( false ) ;
+ this ->set_size_request( 300, 70 ) ;
+
+ /*TO TRANSLATORS: dialog title, looks like Set partition label on /dev/hda3 */
+ this ->set_title( String::ucompose( _("Set partition label on %1"), partition .get_path() ) );
+
+ //Table
+ int top = 0, bottom = 1 ;
+
+ //Create table to hold Label and entry box
+ table = manage( new Gtk::Table() ) ;
+ table ->set_border_width( 5 ) ;
+ table ->set_col_spacings(10 ) ;
+ this ->get_vbox() ->pack_start( *table, Gtk::PACK_SHRINK ) ;
+ //Label
+ table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Label:") ) + "</b>" ),
+ 0, 1,
+ top, bottom,
+ Gtk::FILL ) ;
+ //Create Text entry box
+ entry = manage( new Gtk::Entry() );
+ entry ->set_max_length( 30 );
+ entry ->set_width_chars( 20 );
+ entry ->set_activates_default( true );
+ entry ->set_text( partition.label );
+ entry ->select_region( 0, entry ->get_text_length() );
+ //Add entry box to table
+ table ->attach( *entry,
+ 1, 2,
+ top++, bottom++,
+ Gtk::FILL ) ;
+
+ this ->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL ) ;
+ this ->add_button( Gtk::Stock::OK, Gtk::RESPONSE_OK ) ;
+ this ->set_default_response( Gtk::RESPONSE_OK ) ;
+ this ->show_all_children() ;
+}
+
+Dialog_Partition_Label::~Dialog_Partition_Label()
+{
+}
+
+Glib::ustring Dialog_Partition_Label::get_new_label()
+{
+ return Utils::trim( Glib::ustring( entry ->get_text() ) );
+}
+
+} //GParted
Modified: trunk/src/Dialog_Partition_New.cc
==============================================================================
--- trunk/src/Dialog_Partition_New.cc (original)
+++ trunk/src/Dialog_Partition_New.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -107,7 +107,19 @@
optionmenu_filesystem .signal_changed() .connect(
sigc::bind<bool>( sigc::mem_fun( *this, &Dialog_Partition_New::optionmenu_changed ), false ) );
table_create .attach( optionmenu_filesystem, 1, 2, 1, 2, Gtk::FILL );
-
+
+ //Label
+ table_create .attach( * Utils::mk_label( Glib::ustring( _("Label:") ) ),
+ 0, 1, 3, 4, Gtk::FILL ) ;
+ //Create Text entry box
+ entry .set_max_length( 30 );
+ entry .set_width_chars( 20 );
+ entry .set_activates_default( true );
+ entry .set_text( partition.label );
+ entry .select_region( 0, entry .get_text_length() );
+ //Add entry box to table
+ table_create .attach( entry, 1, 2, 3, 4, Gtk::FILL ) ;
+
//set some widely used values...
START = partition.sector_start ;
total_length = partition.sector_end - partition.sector_start ;
@@ -161,7 +173,10 @@
new_count, part_type,
FILESYSTEMS[ optionmenu_filesystem .get_history() ] .filesystem,
new_start, new_end,
- selected_partition .inside_extended, false ) ;
+ selected_partition .inside_extended, false ) ;
+
+ //Retrieve Label info
+ part_temp .label = Utils::trim( entry .get_text() );
//grow new partition a bit if freespaces are < 1 MiB
if ( (part_temp.sector_start - selected_partition.sector_start) < MEBIBYTE )
Modified: trunk/src/Dialog_Progress.cc
==============================================================================
--- trunk/src/Dialog_Progress.cc (original)
+++ trunk/src/Dialog_Progress.cc Mon Apr 7 20:41:18 2008
@@ -250,7 +250,7 @@
//deal with succes/error...
if ( succes )
{
- str_temp = _("All operations succesfully completed") ;
+ str_temp = _("All operations successfully completed") ;
if ( warnings > 0 )
str_temp += " (" + String::ucompose( _("%1 warnings"), warnings ) + ")" ;
@@ -380,7 +380,7 @@
out << "( EXECUTING )" ;
break ;
case STATUS_SUCCES:
- out << "( SUCCES )" ;
+ out << "( SUCCESS )" ;
break ;
case STATUS_ERROR:
out << "( ERROR )" ;
Modified: trunk/src/GParted_Core.cc
==============================================================================
--- trunk/src/GParted_Core.cc (original)
+++ trunk/src/GParted_Core.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart 'plors' Hakvoort
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -22,6 +22,7 @@
#include "../include/OperationDelete.h"
#include "../include/OperationFormat.h"
#include "../include/OperationResizeMove.h"
+#include "../include/OperationLabelPartition.h"
#include "../include/ext2.h"
#include "../include/ext3.h"
@@ -368,6 +369,9 @@
static_cast<OperationCopy*>( operation ) ->partition_copied .get_length(),
operation ->operation_detail ) ;
break ;
+ case OPERATION_LABEL_PARTITION:
+ succes = label_partition( operation ->partition_new, operation ->operation_detail ) ;
+ break ;
}
if ( libparted_messages .size() > 0 )
@@ -527,10 +531,10 @@
std::ifstream proc_partitions( "/proc/partitions" ) ;
if ( proc_partitions )
{
- char c_str[255] ;
+ char c_str[4096+1] ;
while ( getline( proc_partitions, line ) )
- if ( sscanf( line .c_str(), "%*d %*d %*d %255s", c_str ) == 1 )
+ if ( sscanf( line .c_str(), "%*d %*d %*d %4096s", c_str ) == 1 )
{
line = "/dev/" ;
line += c_str ;
@@ -555,7 +559,7 @@
std::map< Glib::ustring, std::vector<Glib::ustring> > & map )
{
std::string line ;
- char node[255], mountpoint[255] ;
+ char node[4096+1], mountpoint[4096+1] ;
unsigned int index ;
std::ifstream file( filename .c_str() ) ;
@@ -563,7 +567,7 @@
{
while ( getline( file, line ) )
if ( Glib::str_has_prefix( line, "/" ) &&
- sscanf( line .c_str(), "%255s %255s", node, mountpoint ) == 2 &&
+ sscanf( line .c_str(), "%4096s %4096s", node, mountpoint ) == 2 &&
Glib::ustring( node ) != "/dev/root" )
{
line = mountpoint ;
@@ -1111,7 +1115,43 @@
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
return succes ;
}
-
+
+bool GParted_Core::label_partition( const Partition & partition, OperationDetail & operationdetail )
+{
+ if( partition .label .empty() ) {
+ operationdetail .add_child( OperationDetail( String::ucompose(
+ _("Clear partition label on %1"),
+ partition .get_path()
+ ) ) ) ;
+ } else {
+ operationdetail .add_child( OperationDetail( String::ucompose(
+ _("Set partition label to \"%1\" on %2"),
+ partition .label, partition .get_path()
+ ) ) ) ;
+ }
+
+ bool succes = false ;
+ if ( partition .type != TYPE_EXTENDED )
+ {
+ switch( get_fs( partition .filesystem ) .set_label )
+ {
+ case FS::EXTERNAL:
+ succes = set_proper_filesystem( partition .filesystem ) &&
+ p_filesystem ->set_label( partition, operationdetail .get_last_child() ) ;
+ break ;
+ case FS::LIBPARTED:
+ break ;
+
+ default:
+ break ;
+ }
+ }
+
+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
+
+ return succes ;
+}
+
bool GParted_Core::resize_move( const Device & device,
const Partition & partition_old,
Partition & partition_new,
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Apr 7 20:41:18 2008
@@ -15,6 +15,7 @@
Dialog_Disklabel.cc \
Dialog_Partition_Copy.cc \
Dialog_Partition_Info.cc \
+ Dialog_Partition_Label.cc \
Dialog_Partition_New.cc \
Dialog_Partition_Resize_Move.cc \
Dialog_Progress.cc \
@@ -34,6 +35,7 @@
OperationDetail.cc \
OperationFormat.cc \
OperationResizeMove.cc \
+ OperationLabelPartition.cc \
Partition.cc \
TreeView_Detail.cc \
Utils.cc \
Added: trunk/src/OperationLabelPartition.cc
==============================================================================
--- (empty file)
+++ trunk/src/OperationLabelPartition.cc Mon Apr 7 20:41:18 2008
@@ -0,0 +1,69 @@
+/* Copyright (C) 2008 Curtis Gedak
+ *
+ * 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.
+ */
+
+#include "../include/OperationLabelPartition.h"
+
+namespace GParted
+{
+
+OperationLabelPartition::OperationLabelPartition( const Device & device,
+ const Partition & partition_orig,
+ const Partition & partition_new )
+{
+ type = OPERATION_LABEL_PARTITION ;
+
+ this ->device = device ;
+ this ->partition_original = partition_orig ;
+ this ->partition_new = partition_new ;
+}
+
+void OperationLabelPartition::apply_to_visual( std::vector<Partition> & partitions )
+{
+ if ( partition_original .inside_extended )
+ {
+ index_extended = find_index_extended( partitions ) ;
+
+ if ( index_extended >= 0 )
+ index = find_index_original( partitions[ index_extended ] .logicals ) ;
+
+ if ( index >= 0 )
+ partitions[ index_extended ] .logicals[ index ] = partition_new ;
+ }
+ else
+ {
+ index = find_index_original( partitions ) ;
+
+ if ( index >= 0 )
+ partitions[ index ] = partition_new ;
+ }
+}
+
+void OperationLabelPartition::create_description()
+{
+ if( partition_new .label .empty() ) {
+ /*TO TRANSLATORS: looks like Clear Partition Label on /dev/hda3 */
+ description = String::ucompose( _("Clear Partition Label on %1"),
+ partition_new .get_path() ) ;
+ } else {
+ /*TO TRANSLATORS: looks like Set Partition Label "My Label" on /dev/hda3 */
+ description = String::ucompose( _("Set Partition Label \"%1\" on %2"),
+ partition_new .label,
+ partition_new .get_path() ) ;
+ }
+}
+
+} //GParted
Modified: trunk/src/Utils.cc
==============================================================================
--- trunk/src/Utils.cc (original)
+++ trunk/src/Utils.cc Mon Apr 7 20:41:18 2008
@@ -19,6 +19,7 @@
#include <sstream>
#include <iomanip>
+#include <regex.h>
namespace GParted
{
@@ -262,4 +263,75 @@
return exit_status ;
}
+Glib::ustring Utils::regexp_label( const Glib::ustring & text,
+ const Glib::ustring & regular_sub_expression )
+{
+ //Extract text from a regular sub-expression. E.g., "text we don't want (text we want)"
+ Glib::ustring label = "";
+ regex_t preg ;
+ int nmatch = 2 ;
+ regmatch_t pmatch[ 2 ] ;
+ int rc = regcomp( &preg, regular_sub_expression .c_str(), REG_EXTENDED | REG_ICASE | REG_NEWLINE ) ;
+ if ( ( rc == 0 ) //Reg compile OK
+ && ( regexec( &preg, text .c_str(), nmatch, pmatch, 0 ) == 0 ) //Match found
+ )
+ {
+ label = text .substr( pmatch[1].rm_so, pmatch[1].rm_eo - pmatch[1].rm_so ) ;
+ }
+ return label ;
+}
+
+Glib::ustring Utils::create_mtoolsrc_file( char file_name[], const char drive_letter,
+ const Glib::ustring & device_path )
+{
+ //Create mtools config file
+ //NOTE: file_name will be changed by the mkstemp() function call.
+ Glib::ustring err_msg = "" ;
+ int fd ;
+ fd = mkstemp( file_name ) ;
+ if( fd != -1 ) {
+ Glib::ustring fcontents =
+ _("# Temporary file created by gparted. It may be deleted.\n") ;
+
+ //The following file contents are mtools keywords (see man mtools.conf)
+ fcontents = String::ucompose(
+ "drive %1: file=\"%2\"\nmtools_skip_check=1\n", drive_letter, device_path
+ );
+
+ if( write( fd, fcontents .c_str(), fcontents .size() ) == -1 ) {
+ err_msg = String::ucompose(
+ _("Label operation failed: Unable to write to temporary file %1.\n")
+ , file_name
+ ) ;
+ }
+ close( fd ) ;
+ }
+ else
+ {
+ err_msg = String::ucompose(
+ _("Label operation failed: Unable to create temporary file %1.\n")
+ , file_name
+ ) ;
+ }
+ return err_msg ;
+}
+
+Glib::ustring Utils::delete_mtoolsrc_file( const char file_name[] )
+{
+ //Delete mtools config file
+ Glib::ustring err_msg = "" ;
+ remove( file_name ) ;
+ return err_msg ;
+}
+
+Glib::ustring Utils::trim( const Glib::ustring & src, const Glib::ustring & c /* = " \t\r\n" */ )
+{
+ //Trim leading and trailing whitespace from string
+ Glib::ustring::size_type p2 = src.find_last_not_of(c);
+ if (p2 == Glib::ustring::npos) return Glib::ustring();
+ Glib::ustring::size_type p1 = src.find_first_not_of(c);
+ if (p1 == Glib::ustring::npos) p1 = 0;
+ return src.substr(p1, (p2-p1)+1);
+}
+
} //GParted..
Modified: trunk/src/Win_GParted.cc
==============================================================================
--- trunk/src/Win_GParted.cc (original)
+++ trunk/src/Win_GParted.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -23,6 +23,7 @@
#include "../include/Dialog_Partition_Copy.h"
#include "../include/Dialog_Partition_New.h"
#include "../include/Dialog_Partition_Info.h"
+#include "../include/Dialog_Partition_Label.h"
#include "../include/DialogManageFlags.h"
#include "../include/OperationCopy.h"
#include "../include/OperationCheck.h"
@@ -30,6 +31,7 @@
#include "../include/OperationDelete.h"
#include "../include/OperationFormat.h"
#include "../include/OperationResizeMove.h"
+#include "../include/OperationLabelPartition.h"
#include <gtkmm/aboutdialog.h>
#include <gtkmm/messagedialog.h>
@@ -59,6 +61,7 @@
MENU_MOUNT =
MENU_FLAGS =
MENU_INFO =
+ MENU_LABEL_PARTITION =
TOOLBAR_UNDO =
TOOLBAR_APPLY = -1 ;
@@ -340,6 +343,11 @@
sigc::mem_fun( *this, &Win_GParted::activate_check ) ) );
MENU_CHECK = index++ ;
+ menu_partition .items() .push_back(
+ Gtk::Menu_Helpers::MenuElem( _("_Label"),
+ sigc::mem_fun( *this, &Win_GParted::activate_label_partition ) ) );
+ MENU_LABEL_PARTITION = index++ ;
+
menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ) ;
index++ ;
@@ -736,7 +744,8 @@
{
allow_new( false ); allow_delete( false ); allow_resize( false ); allow_copy( false );
allow_paste( false ); allow_format( false ); allow_toggle_swap_mount_state( false ) ;
- allow_manage_flags( false ) ; allow_check( false ) ; allow_info( false ) ;
+ allow_manage_flags( false ) ; allow_check( false ) ; allow_label_partition( false ) ;
+ allow_info( false ) ;
dynamic_cast<Gtk::Label*>( menu_partition .items()[ MENU_TOGGLE_MOUNT_SWAP ] .get_child() )
->set_label( _("_Unmount") ) ;
@@ -831,8 +840,12 @@
//only allow copying of real partitions
if ( selected_partition .status == GParted::STAT_REAL && fs .copy )
- allow_copy( true ) ;
-
+ allow_copy( true ) ;
+
+ //only allow labelling of real partitions that support labelling
+ if ( selected_partition .status == GParted::STAT_REAL && fs .set_label )
+ allow_label_partition( true ) ;
+
if ( selected_partition .get_mountpoints() .size() )
{
allow_toggle_swap_mount_state( true ) ;
@@ -1138,10 +1151,11 @@
dialog .set_logo( this ->get_icon() ) ;
dialog .set_version( VERSION ) ;
dialog .set_comments( _( "GNOME Partition Editor" ) ) ;
- dialog .set_copyright( "Copyright  2004-2006 Bart Hakvoort" ) ;
+ dialog .set_copyright( "Copyright  2004-2008 Bart Hakvoort" ) ;
//authors
strings .push_back( "Bart Hakvoort <gparted users sf net>" ) ;
+ strings .push_back( "Curtis Gedak <gedakc users sf net>" ) ;
dialog .set_authors( strings ) ;
strings .clear() ;
@@ -1784,6 +1798,36 @@
Add_Operation( operation ) ;
}
+void Win_GParted::activate_label_partition()
+{
+ Dialog_Partition_Label dialog( selected_partition );
+ dialog .set_transient_for( *this );
+
+ if ( ( dialog .run() == Gtk::RESPONSE_OK )
+ && ( dialog .get_new_label() != selected_partition .label ) )
+ {
+ dialog .hide() ;
+ //Make a duplicate of the selected partition (used in UNDO)
+ Partition part_temp ;
+ part_temp .Set( devices[ current_device ] .get_path(),
+ selected_partition .get_path(),
+ selected_partition .partition_number,
+ selected_partition .type,
+ selected_partition .filesystem,
+ selected_partition .sector_start,
+ selected_partition .sector_end,
+ selected_partition .inside_extended,
+ false ) ;
+
+ part_temp .label = dialog .get_new_label();
+
+ Operation * operation = new OperationLabelPartition( devices[ current_device ],
+ selected_partition, part_temp ) ;
+ operation ->icon = render_icon( Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU );
+ Add_Operation( operation ) ;
+ }
+}
+
void Win_GParted::activate_undo()
{
//when undoing a creation it's safe to decrease the newcount by one
Modified: trunk/src/ext2.cc
==============================================================================
--- trunk/src/ext2.cc (original)
+++ trunk/src/ext2.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -28,8 +28,10 @@
if ( ! Glib::find_program_in_path( "dumpe2fs" ) .empty() )
fs .read = FS::EXTERNAL ;
- if ( ! Glib::find_program_in_path( "e2label" ) .empty() )
+ if ( ! Glib::find_program_in_path( "e2label" ) .empty() ) {
fs .get_label = FS::EXTERNAL ;
+ fs .set_label = FS::EXTERNAL ;
+ }
if ( ! Glib::find_program_in_path( "mkfs.ext2" ) .empty() )
fs .create = FS::EXTERNAL ;
@@ -85,10 +87,7 @@
{
if ( ! Utils::execute_command( "e2label " + partition .get_path(), output, error, true ) )
{
- if ( output .size() > 0 && output[ output .size() -1 ] == '\n' )
- partition .label = output .substr( 0, output .size() -1 ) ;
- else
- partition .label = output ;
+ partition .label = Utils::regexp_label( output, "^(.*)" ) ;
}
else
{
@@ -100,9 +99,14 @@
}
}
+bool ext2::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
+}
+
bool ext2::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkfs.ext2 " + new_partition .get_path(), operationdetail ) ;
+ return ! execute_command( "mkfs.ext2 -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
}
bool ext2::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
Modified: trunk/src/ext3.cc
==============================================================================
--- trunk/src/ext3.cc (original)
+++ trunk/src/ext3.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -29,9 +29,11 @@
if ( ! Glib::find_program_in_path( "dumpe2fs" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
- if ( ! Glib::find_program_in_path( "e2label" ) .empty() )
+ if ( ! Glib::find_program_in_path( "e2label" ) .empty() ) {
fs .get_label = FS::EXTERNAL ;
-
+ fs .set_label = FS::EXTERNAL ;
+ }
+
if ( ! Glib::find_program_in_path( "mkfs.ext3" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
@@ -86,10 +88,7 @@
{
if ( ! Utils::execute_command( "e2label " + partition .get_path(), output, error, true ) )
{
- if ( output .size() > 0 && output[ output .size() -1 ] == '\n' )
- partition .label = output .substr( 0, output .size() -1 ) ;
- else
- partition .label = output ;
+ partition .label = Utils::regexp_label( output, "^(.*)" ) ;
}
else
{
@@ -101,9 +100,14 @@
}
}
+bool ext3::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ return ! execute_command( "e2label " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
+}
+
bool ext3::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkfs.ext3 " + new_partition .get_path(), operationdetail ) ;
+ return ! execute_command( "mkfs.ext3 -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
}
bool ext3::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
Modified: trunk/src/fat16.cc
==============================================================================
--- trunk/src/fat16.cc (original)
+++ trunk/src/fat16.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -18,6 +18,13 @@
#include "../include/fat16.h"
+/*****
+//For some reason unknown, this works without these include statements.
+#include <stdlib.h> // 'C' library for mkstemp()
+#include <unistd.h> // 'C' library for write(), close()
+#include <stdio.h> // 'C' library for remove()
+*****/
+
namespace GParted
{
@@ -35,7 +42,12 @@
fs .check = GParted::FS::EXTERNAL ;
fs .read = GParted::FS::EXTERNAL ;
}
-
+
+ if ( ! Glib::find_program_in_path( "mlabel" ) .empty() ) {
+ fs .get_label = FS::EXTERNAL ;
+ fs .set_label = FS::EXTERNAL ;
+ }
+
//resizing of start and endpoint are provided by libparted
fs .grow = GParted::FS::LIBPARTED ;
fs .shrink = GParted::FS::LIBPARTED ;
@@ -81,11 +93,66 @@
void fat16::get_label( Partition & partition )
{
+ //Create mtools config file
+ char fname[] = "/tmp/gparted-XXXXXXXX" ;
+ char dletter = 'H' ;
+ Glib::ustring err_msg = "" ;
+ err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
+ if( err_msg.length() != 0 )
+ partition .messages .push_back( err_msg );
+
+ Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -s %2:", fname, dletter ) ;
+
+ if ( ! Utils::execute_command( cmd, output, error, true ) )
+ {
+ partition .label = Utils::regexp_label( output, "Volume label is ([^(]*)" );
+ }
+ else
+ {
+ if ( ! output .empty() )
+ partition .messages .push_back( output ) ;
+
+ if ( ! error .empty() )
+ partition .messages .push_back( error ) ;
+ }
+
+ //Delete mtools config file
+ err_msg = Utils::delete_mtoolsrc_file( fname );
}
+
+bool fat16::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ //Create mtools config file
+ char fname[] = "/tmp/gparted-XXXXXXXX" ;
+ char dletter = 'H' ;
+ Glib::ustring err_msg = "" ;
+ err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
+
+ Glib::ustring cmd = "" ;
+ if( partition .label .empty() )
+ cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
+ else
+ cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, partition .label ) ;
+ operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
+
+ int exit_status = Utils::execute_command( cmd, output, error ) ;
+
+ if ( ! output .empty() )
+ operationdetail .get_last_child() .add_child( OperationDetail( output, STATUS_NONE, FONT_ITALIC ) ) ;
+
+ if ( ! error .empty() )
+ operationdetail .get_last_child() .add_child( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ;
+
+ //Delete mtools config file
+ err_msg = Utils::delete_mtoolsrc_file( fname );
+
+ return ( exit_status == 0 );
+}
+
bool fat16::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkdosfs -F16 -v " + new_partition .get_path(), operationdetail ) ;
+ return ! execute_command( "mkdosfs -F16 -v -n \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
}
bool fat16::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
Modified: trunk/src/fat32.cc
==============================================================================
--- trunk/src/fat32.cc (original)
+++ trunk/src/fat32.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -18,6 +18,13 @@
#include "../include/fat32.h"
+/*****
+//For some reason unknown, this works without these include statements.
+#include <stdlib.h> // 'C' library for mkstemp()
+#include <unistd.h> // 'C' library for write(), close()
+#include <stdio.h> // 'C' library for remove()
+*****/
+
namespace GParted
{
@@ -35,7 +42,12 @@
fs .check = GParted::FS::EXTERNAL ;
fs .read = GParted::FS::EXTERNAL ;
}
-
+
+ if ( ! Glib::find_program_in_path( "mlabel" ) .empty() ) {
+ fs .get_label = FS::EXTERNAL ;
+ fs .set_label = FS::EXTERNAL ;
+ }
+
//resizing of start and endpoint are provided by libparted
fs .grow = GParted::FS::LIBPARTED ;
fs .shrink = GParted::FS::LIBPARTED ;
@@ -81,11 +93,65 @@
void fat32::get_label( Partition & partition )
{
+ //Create mtools config file
+ char fname[] = "/tmp/gparted-XXXXXXXX" ;
+ char dletter = 'H' ;
+ Glib::ustring err_msg = "" ;
+ err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
+ if( err_msg.length() != 0 )
+ partition .messages .push_back( err_msg );
+
+ Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -s %2:", fname, dletter ) ;
+
+ if ( ! Utils::execute_command( cmd, output, error, true ) )
+ {
+ partition .label = Utils::regexp_label( output, "Volume label is ([^(]*)" );
+ }
+ else
+ {
+ if ( ! output .empty() )
+ partition .messages .push_back( output ) ;
+
+ if ( ! error .empty() )
+ partition .messages .push_back( error ) ;
+ }
+
+ //Delete mtools config file
+ err_msg = Utils::delete_mtoolsrc_file( fname );
+}
+
+bool fat32::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ //Create mtools config file
+ char fname[] = "/tmp/gparted-XXXXXXXX" ;
+ char dletter = 'H' ;
+ Glib::ustring err_msg = "" ;
+ err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
+
+ Glib::ustring cmd = "" ;
+ if( partition .label .empty() )
+ cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
+ else
+ cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, partition .label ) ;
+ operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
+
+ int exit_status = Utils::execute_command( cmd, output, error ) ;
+
+ if ( ! output .empty() )
+ operationdetail .get_last_child() .add_child( OperationDetail( output, STATUS_NONE, FONT_ITALIC ) ) ;
+
+ if ( ! error .empty() )
+ operationdetail .get_last_child() .add_child( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ;
+
+ //Delete mtools config file
+ err_msg = Utils::delete_mtoolsrc_file( fname );
+
+ return ( exit_status == 0 );
}
bool fat32::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkdosfs -F32 -v " + new_partition .get_path(), operationdetail ) ;
+ return ! execute_command( "mkdosfs -F32 -v -n \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
}
bool fat32::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
Modified: trunk/src/hfs.cc
==============================================================================
--- trunk/src/hfs.cc (original)
+++ trunk/src/hfs.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -80,9 +80,19 @@
}
}
+bool hfs::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ return true ;
+}
+
bool hfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "hformat " + new_partition .get_path(), operationdetail ) ;
+ Glib::ustring cmd = "";
+ if( new_partition .label .empty() )
+ cmd = "hformat " + new_partition .get_path() ;
+ else
+ cmd = "hformat -l \"" + new_partition .label + "\" " + new_partition .get_path() ;
+ return ! execute_command( cmd , operationdetail ) ;
}
bool hfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
Modified: trunk/src/hfsplus.cc
==============================================================================
--- trunk/src/hfsplus.cc (original)
+++ trunk/src/hfsplus.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -44,6 +44,11 @@
{
}
+bool hfsplus::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ return true ;
+}
+
bool hfsplus::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return true ;
Modified: trunk/src/jfs.cc
==============================================================================
--- trunk/src/jfs.cc (original)
+++ trunk/src/jfs.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -31,9 +31,11 @@
if ( ! Glib::find_program_in_path( "jfs_debugfs" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
- if ( ! Glib::find_program_in_path( "jfs_tune" ) .empty() )
+ if ( ! Glib::find_program_in_path( "jfs_tune" ) .empty() ) {
fs .get_label = FS::EXTERNAL ;
-
+ fs .set_label = FS::EXTERNAL ;
+ }
+
if ( ! Glib::find_program_in_path( "mkfs.jfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
@@ -106,20 +108,7 @@
{
if ( ! Utils::execute_command( "jfs_tune -l " + partition .get_path(), output, error, true ) )
{
- char buf[512] ;
- index = output .find( "Volume label:" ) ;
-
- if ( index < output .length() && sscanf( output .substr( index ) .c_str(), "Volume label: %512s", buf ) == 1 )
- {
- partition .label = buf ;
-
- //remove '' from the label..
- if ( partition .label .size() > 0 && partition .label[0] == '\'' )
- partition .label = partition .label .substr( 1 ) ;
-
- if ( partition .label .size() > 0 && partition .label[ partition .label .size() -1 ] == '\'' )
- partition .label = partition .label .substr( 0, partition .label .size() -1 ) ;
- }
+ partition .label = Utils::regexp_label( output, "^Volume label:[\t ]*'(.*)'" ) ;
}
else
{
@@ -131,9 +120,14 @@
}
}
+bool jfs::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ return ! execute_command( "jfs_tune -L \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
+}
+
bool jfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkfs.jfs -q " + new_partition .get_path(), operationdetail ) ;
+ return ! execute_command( "mkfs.jfs -q -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
}
bool jfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
Modified: trunk/src/linux_swap.cc
==============================================================================
--- trunk/src/linux_swap.cc (original)
+++ trunk/src/linux_swap.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -32,7 +32,10 @@
fs .grow = GParted::FS::EXTERNAL ;
fs .shrink = GParted::FS::EXTERNAL ;
}
-
+
+ if ( ! Glib::find_program_in_path( "vol_id" ) .empty() )
+ fs .get_label = FS::EXTERNAL ;
+
fs .copy = GParted::FS::GPARTED ;
fs .move = GParted::FS::GPARTED ;
@@ -45,11 +48,28 @@
void linux_swap::get_label( Partition & partition )
{
+ if ( ! Utils::execute_command( "vol_id --label-raw " + partition .get_path(), output, error, true ) )
+ {
+ partition .label = Utils::regexp_label( output, "^(.*)" ) ;
+ }
+ else
+ {
+ if ( ! output .empty() )
+ partition .messages .push_back( output ) ;
+
+ if ( ! error .empty() )
+ partition .messages .push_back( error ) ;
+ }
+}
+
+bool linux_swap::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ return true ;
}
bool linux_swap::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkswap " + new_partition .get_path(), operationdetail ) ;
+ return ! execute_command( "mkswap -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
}
bool linux_swap::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
Modified: trunk/src/ntfs.cc
==============================================================================
--- trunk/src/ntfs.cc (original)
+++ trunk/src/ntfs.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -32,9 +32,11 @@
fs .check = GParted::FS::EXTERNAL ;
}
- if ( ! Glib::find_program_in_path( "ntfslabel" ) .empty() )
+ if ( ! Glib::find_program_in_path( "ntfslabel" ) .empty() ) {
fs .get_label = FS::EXTERNAL ;
-
+ fs .set_label = FS::EXTERNAL ;
+ }
+
if ( ! Glib::find_program_in_path( "mkntfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
@@ -84,10 +86,7 @@
{
if ( ! Utils::execute_command( "ntfslabel --force " + partition .get_path(), output, error, true ) )
{
- if ( output .size() > 0 && output[ output .size() -1 ] == '\n' )
- partition .label = output .substr( 0, output .size() -1 ) ;
- else
- partition .label = output ;
+ partition .label = Utils::regexp_label( output, "^(.*)" ) ;
}
else
{
@@ -99,9 +98,14 @@
}
}
+bool ntfs::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ return ! execute_command( "ntfslabel --force " + partition .get_path() + " \"" + partition .label + "\"", operationdetail ) ;
+}
+
bool ntfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkntfs -Q -vv " + new_partition .get_path(), operationdetail ) ;
+ return ! execute_command( "mkntfs -Q -vv -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
}
bool ntfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
Modified: trunk/src/reiser4.cc
==============================================================================
--- trunk/src/reiser4.cc (original)
+++ trunk/src/reiser4.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -84,14 +84,10 @@
{
if ( ! Utils::execute_command( "debugfs.reiser4 " + partition .get_path(), output, error, true ) )
{
- char buf[512] ;
- index = output .find( "label" ) ;
-
+ Glib::ustring label = Utils::regexp_label( output, "^label:[\t ]*([^!]*)" ) ;
//FIXME: find a better way to see if label is empty.. imagine someone uses '<none>' as label.... ;)
- if ( index < output .length() &&
- sscanf( output .substr( index ) .c_str(), "label: %512s", buf ) == 1 &&
- Glib::ustring( buf ) != "<none>" )
- partition .label = buf ;
+ if( label != "<none>" )
+ partition .label = label ;
}
else
{
@@ -103,9 +99,14 @@
}
}
+bool reiser4::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ return true ;
+}
+
bool reiser4::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkfs.reiser4 --yes " + new_partition .get_path(), operationdetail ) ;
+ return ! execute_command( "mkfs.reiser4 --yes --label \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
}
bool reiser4::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
Modified: trunk/src/reiserfs.cc
==============================================================================
--- trunk/src/reiserfs.cc (original)
+++ trunk/src/reiserfs.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -31,7 +31,10 @@
fs .read = GParted::FS::EXTERNAL ;
fs .get_label = FS::EXTERNAL ;
}
-
+
+ if ( ! Glib::find_program_in_path( "reiserfstune" ) .empty() )
+ fs .set_label = FS::EXTERNAL ;
+
if ( ! Glib::find_program_in_path( "mkreiserfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
@@ -90,11 +93,7 @@
//FIXME: i think running debugreiserfs takes a long time on filled filesystems, test for this...
if ( ! Utils::execute_command( "debugreiserfs " + partition .get_path(), output, error, true ) )
{
- char buf[512] ;
- index = output .find( "LABEL" ) ;
-
- if ( index < output .length() && sscanf( output .substr( index ) .c_str(), "LABEL: %512s", buf ) == 1 )
- partition .label = buf ;
+ partition .label = Utils::regexp_label( output, "^label:[\t ]*(.*)" ) ;
}
else
{
@@ -106,9 +105,14 @@
}
}
+bool reiserfs::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ return ! execute_command( "reiserfstune --label \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
+}
+
bool reiserfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkreiserfs -f " + new_partition .get_path(), operationdetail ) ;
+ return ! execute_command( "mkreiserfs -f --label \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
}
bool reiserfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
Modified: trunk/src/ufs.cc
==============================================================================
--- trunk/src/ufs.cc (original)
+++ trunk/src/ufs.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -41,6 +41,11 @@
{
}
+bool ufs::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ return true ;
+}
+
bool ufs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return true ;
Modified: trunk/src/xfs.cc
==============================================================================
--- trunk/src/xfs.cc (original)
+++ trunk/src/xfs.cc Mon Apr 7 20:41:18 2008
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Bart
+/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort
*
* 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
@@ -33,7 +33,10 @@
fs .read = GParted::FS::EXTERNAL ;
fs .get_label = FS::EXTERNAL ;
}
-
+
+ if ( ! Glib::find_program_in_path( "xfs_admin" ) .empty() )
+ fs .set_label = FS::EXTERNAL ;
+
if ( ! Glib::find_program_in_path( "mkfs.xfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
@@ -106,20 +109,9 @@
void xfs::get_label( Partition & partition )
{
- if ( ! Utils::execute_command( "xfs_db -c 'label' " + partition .get_path(), output, error, true ) )
+ if ( ! Utils::execute_command( "xfs_db -r -c 'label' " + partition .get_path(), output, error, true ) )
{
- char buf[512] ;
- if ( sscanf( output .c_str(), "label = %512s", buf ) == 1 )
- {
- partition .label = buf ;
-
- //remove "" from the label..
- if ( partition .label .size() > 0 && partition .label[0] == '\"' )
- partition .label = partition .label .substr( 1 ) ;
-
- if ( partition .label .size() > 0 && partition .label[ partition .label .size() -1 ] == '\"' )
- partition .label = partition .label .substr( 0, partition .label .size() -1 ) ;
- }
+ partition .label = Utils::regexp_label( output, "^label = \"(.*)\"" ) ;
}
else
{
@@ -129,12 +121,25 @@
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
+}
+bool xfs::set_label( const Partition & partition, OperationDetail & operationdetail )
+{
+ Glib::ustring cmd = "" ;
+ if( partition .label .empty() )
+ cmd = String::ucompose( "xfs_admin -L -- %1", partition .get_path() ) ;
+ else
+ cmd = String::ucompose( "xfs_admin -L \"%1\" %2", partition .label, partition .get_path() ) ;
+ return ! execute_command( cmd, operationdetail ) ;
}
bool xfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkfs.xfs -f " + new_partition .get_path(), operationdetail ) ;
+ //mkfs.xfs will not create filesystem if label is longer than 12 characters, hence truncation.
+ Glib::ustring label = new_partition .label ;
+ if( label .length() > 12 )
+ label = label.substr( 0, 12 ) ;
+ return ! execute_command( "mkfs.xfs -f -L \"" + label + "\" " + new_partition .get_path(), operationdetail ) ;
}
bool xfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]