Add methods to FS_Info class to get path by uuid and by label

This commit is contained in:
Curtis Gedak 2010-12-09 14:06:38 -07:00
parent 3973b6961d
commit 128b1439a1
2 changed files with 21 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2008, 2009 Curtis Gedak
/* Copyright (C) 2008, 2009, 2010 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
@ -32,6 +32,8 @@ public:
Glib::ustring get_fs_type( const Glib::ustring & path ) ;
Glib::ustring get_label( const Glib::ustring & path, bool & found ) ;
Glib::ustring get_uuid( const Glib::ustring & path ) ;
Glib::ustring get_path_by_uuid( const Glib::ustring & uuid ) ;
Glib::ustring get_path_by_label( const Glib::ustring & label ) ;
private:
void load_fs_info_cache() ;
void set_commands_found() ;

View File

@ -153,4 +153,22 @@ Glib::ustring FS_Info::get_uuid( const Glib::ustring & path )
return uuid ;
}
Glib::ustring FS_Info::get_path_by_uuid( const Glib::ustring & uuid )
{
//Retrieve the path given the uuid
Glib::ustring regexp = "^([^:]*):.*UUID=\"" + uuid + "\".*$" ;
Glib::ustring path = Utils::regexp_label( fs_info_cache, regexp ) ;
return path ;
}
Glib::ustring FS_Info::get_path_by_label( const Glib::ustring & label )
{
//Retrieve the path given the label
Glib::ustring regexp = "^([^:]*):.*LABEL=\"" + label + "\".*$" ;
Glib::ustring path = Utils::regexp_label( fs_info_cache, regexp ) ;
return path ;
}
}//GParted