Created class to read file system UUIDs

svn path=/trunk/; revision=960
This commit is contained in:
Curtis Gedak 2008-11-11 17:19:46 +00:00
parent 352641208a
commit 135e60141f
6 changed files with 109 additions and 4 deletions

10
AUTHORS
View File

@ -12,13 +12,15 @@ 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). We need to keep track of copyright (see the Maintainer HOWTO on www.gnu.org).
Curtis Gedak <gedakc@users.sourceforge.net> Curtis Gedak <gedakc@users.sourceforge.net>
* Wrote Utils::fat_compliant_label() method * Created FS_Info.h, FS_Info.cc
* Wrote Utils::cleanup_cursor() function
* Rewrote read_label functionality for hfs * Rewrote read_label functionality for hfs
* Wrote create, read_label, and check_repair functionality for hfs+ * Wrote create, read_label, and check_repair functionality for hfs+
* Wrote read_label functionality for fat16 and fat32 filesystems * Wrote read_label functionality for fat16 and fat32 filesystems
* Wrote Utils::regexp_label() function * Wrote following Utils:: methods:
* Wrote write partition label functionality regexp_label(), fat_compliant_label(),
create_mtoolsrc_file(), delete_mtoolsrc_file,
trim(), cleanup_cursor(), get_lang()
* Wrote partition write_label functionality
* Created Dialog_Partion_Label.h, Dialog_Partition_Label.cc * Created Dialog_Partion_Label.h, Dialog_Partition_Label.cc
* Created OperationLabelPartition.h, OperationLabelPartition.cc * Created OperationLabelPartition.h, OperationLabelPartition.cc
* Maintained from official 0.3.5 release onward * Maintained from official 0.3.5 release onward

View File

@ -1,3 +1,10 @@
2008-11-11 Curtis Gedak <gedakc@gmail.com>
* include/FS_Info.h,
include/Makefile.am,
src/FS_Info.cc,
src/Makefile.am: Created class to read file system UUIDs.
2008-11-10 Curtis Gedak <gedakc@gmail.com> 2008-11-10 Curtis Gedak <gedakc@gmail.com>
* src/fat16.cc, * src/fat16.cc,

39
include/FS_Info.h Normal file
View File

@ -0,0 +1,39 @@
/* 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 FS_INFO_H_
#define FS_INFO_H_
#include "../include/Utils.h"
namespace GParted
{
class FS_Info
{
public:
FS_Info() ;
~FS_Info() ;
Glib::ustring get_uuid( const Glib::ustring & path ) ;
private:
void load_fs_info_cache() ;
Glib::ustring fs_info_cache ;
};
}//GParted
#endif /*FS_INFO_H_*/

View File

@ -16,6 +16,7 @@ EXTRA_DIST = \
FileSystem.h \ FileSystem.h \
Frame_Resizer_Base.h \ Frame_Resizer_Base.h \
Frame_Resizer_Extended.h \ Frame_Resizer_Extended.h \
FS_Info.h \
GParted_Core.h \ GParted_Core.h \
HBoxOperations.h \ HBoxOperations.h \
Operation.h \ Operation.h \

55
src/FS_Info.cc Normal file
View File

@ -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.
*/
#include "../include/FS_Info.h"
namespace GParted
{
FS_Info::FS_Info()
{
load_fs_info_cache() ;
}
FS_Info::~FS_Info()
{
}
void FS_Info::load_fs_info_cache()
{
Glib::ustring output, error ;
if ( ! Glib::find_program_in_path( "blkid" ) .empty() )
{
if ( ! Utils::execute_command( "blkid -c /dev/null", output, error, true ) )
fs_info_cache = output ;
else
fs_info_cache = "" ;
}
}
Glib::ustring FS_Info::get_uuid( const Glib::ustring & path )
{
//Retrieve the line containing the device path
Glib::ustring regexp = "^" + path + ":([^\n]*)$" ;
Glib::ustring temp = Utils::regexp_label( fs_info_cache, regexp ) ;
//Retrieve the UUID
Glib::ustring uuid = Utils::regexp_label( temp, "UUID=\"([^\"]*)\"" ) ;
return uuid ;
}
}//GParted

View File

@ -25,6 +25,7 @@ gpartedbin_SOURCES = \
FileSystem.cc \ FileSystem.cc \
Frame_Resizer_Base.cc \ Frame_Resizer_Base.cc \
Frame_Resizer_Extended.cc \ Frame_Resizer_Extended.cc \
FS_Info.cc \
GParted_Core.cc \ GParted_Core.cc \
HBoxOperations.cc \ HBoxOperations.cc \
Operation.cc \ Operation.cc \