[gparted] Add methods to FS_Info class to get path by uuid and by label



commit 128b1439a132120bb5eafbc784b4467c4efae954
Author: Curtis Gedak <gedakc gmail com>
Date:   Thu Dec 9 14:06:38 2010 -0700

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

 include/FS_Info.h |    4 +++-
 src/FS_Info.cc    |   18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/include/FS_Info.h b/include/FS_Info.h
index 152d726..da9603d 100644
--- a/include/FS_Info.h
+++ b/include/FS_Info.h
@@ -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() ;
diff --git a/src/FS_Info.cc b/src/FS_Info.cc
index 666fc9d..2aaa098 100644
--- a/src/FS_Info.cc
+++ b/src/FS_Info.cc
@@ -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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]