Changeset 71412 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Mar 20, 2018 4:27:18 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.cpp
r71388 r71412 1333 1333 } 1334 1334 1335 QString UIGuestControlFileTable::humanReadableSize(ULONG64 size) 1336 { 1337 int i = 0; 1338 double dSize = size; 1339 const char* units[] = {" B", " kB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB"}; 1340 while (size > 1024) { 1341 size /= 1024; 1342 dSize /= (double)1024; 1343 i++; 1344 } 1345 if (i > 8) 1346 return QString(); 1347 1348 QString strResult(QString::number(dSize, 'f', 2)); 1349 strResult += units[i]; 1350 return strResult; 1351 } 1352 1353 1335 1354 #include "UIGuestControlFileTable.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.h
r71388 r71412 182 182 void keyPressEvent(QKeyEvent * pEvent); 183 183 CGuestFsObjInfo guestFsObjectInfo(const QString& path, CGuestSession &comGuestSession) const; 184 184 static QString humanReadableSize(ULONG64 size); 185 185 186 186 UIFileTableItem *m_pRootItem; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.cpp
r71391 r71412 148 148 return; 149 149 150 QString userHome = UIPathOperations::sanitize(m_comGuestSession.GetUserHome()); 150 QString userHome = UIPathOperations::sanitize(m_comGuestSession.GetUserHome()).remove(0,1); 151 151 152 QList<QString> pathTrail = userHome.split(UIPathOperations::delimiter); 152 153 … … 306 307 propertyString += "<br/>"; 307 308 /* Size: */ 308 propertyString += "<b>Size:</b> " + QString::number(fileInfo.GetObjectSize()) + QString(" bytes"); 309 LONG64 size = fileInfo.GetObjectSize(); 310 propertyString += "<b>Size:</b> " + QString::number(size) + QString(" bytes"); 311 if (size >= 1024) 312 propertyString += " (" + humanReadableSize(size) + ")"; 309 313 propertyString += "<br/>"; 310 314 /* Type: */ … … 312 316 propertyString += "<br/>"; 313 317 /* Creation Date: */ 314 // LONG64 GetChangeTime() const;315 318 propertyString += "<b>Created:</b> " + QDateTime::fromMSecsSinceEpoch(fileInfo.GetChangeTime()/1000000).toString(); 316 319 propertyString += "<br/>"; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIHostFileTable.cpp
r71388 r71412 194 194 /* Size: */ 195 195 propertyString += "<b>Size:</b> " + QString::number(fileInfo.size()) + QString(" bytes"); 196 if (fileInfo.size() >= 1024) 197 propertyString += " (" + humanReadableSize(fileInfo.size()) + ")"; 196 198 propertyString += "<br/>"; 197 199 /* Type: */ … … 207 209 propertyString += "<b>Owner:</b> " + fileInfo.owner(); 208 210 209 211 if (fileInfo.isDir()) 212 directoryStatisticsRecursive(fileInfo.absoluteFilePath()); 210 213 return propertyString; 211 214 } 212 215 return QString(); 213 216 } 217 218 void UIHostFileTable::directoryStatisticsRecursive(const QString &path) 219 { 220 QDir dir(path); 221 if (!dir.exists()) 222 return; 223 224 QFileInfoList entryList = dir.entryInfoList(); 225 for (int i = 0; i < entryList.size(); ++i) 226 { 227 228 const QFileInfo &entryInfo = entryList.at(i); 229 if (entryInfo.baseName().isEmpty() || entryInfo.baseName() == "." || entryInfo.baseName() == "..") 230 continue; 231 232 if (entryInfo.isSymLink()) 233 continue; 234 if (entryInfo.isDir()) 235 { 236 directoryStatisticsRecursive(entryInfo.absoluteFilePath()); 237 } 238 } 239 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIHostFileTable.h
r71388 r71412 43 43 virtual QString fsObjectPropertyString() /* override */; 44 44 45 private: 46 47 /** Read the directory with the path @p path recursively and collect #of objects and 48 total size */ 49 void directoryStatisticsRecursive(const QString &path); 50 45 51 }; 46 52
Note:
See TracChangeset
for help on using the changeset viewer.