[PC-BSD Commits] r18716 - pcbsd/current/src-qt4/pc-mounttray

svn at pcbsd.org svn at pcbsd.org
Wed Aug 29 13:20:07 PDT 2012


Author: kenmoore
Date: 2012-08-29 20:20:07 +0000 (Wed, 29 Aug 2012)
New Revision: 18716

Modified:
   pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp
Log:
Revise the new USB device storage detection algorithm for pc-mounttray



Modified: pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp	2012-08-29 18:39:55 UTC (rev 18715)
+++ pcbsd/current/src-qt4/pc-mounttray/mountTray.cpp	2012-08-29 20:20:07 UTC (rev 18716)
@@ -125,7 +125,20 @@
   QString output = Utils::runShellCommand(cmd).join(" ");
   //qDebug() << "File -s output:" << output;  
   // - get the device storage size
-  int kb = output.section("sectors ",1,1).section(",",0,0).section("(",0,0).simplified().toInt();
+  QStringList tmp = output.split(",");
+  int kb;
+  //qDebug() << "tmp:" << tmp;
+  if( !tmp.filter("number of data blocks").isEmpty() ){
+    tmp = tmp.filter("number of data blocks");
+    kb = tmp[0].remove("number of data blocks").simplified().toInt();
+  }else if( !tmp.filter("number of blocks").isEmpty() ){
+    tmp = tmp.filter("number of blocks");
+    kb = tmp[0].remove("number of blocks").simplified().toInt();
+  }else if( !tmp.filter("sectors ").isEmpty()){
+    tmp = tmp.filter("sectors ");
+    kb = tmp[0].remove("sectors ").section("(",0,0).simplified().toInt();
+  }else{ kb = 1; }
+
   //Filter out all devices with less than a MB of storage
   //qDebug() << "kb detected:" << kb;
   if( (kb < 1024) && (type=="USB") ){



More information about the Commits mailing list