From 8891ba903cf6cd5e95e5b12e05138be62795aa0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Tue, 23 Jul 2019 20:32:06 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@831 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- src_main/system/pisysteminfo.cpp | 20 +++++++++++++++++--- src_main/system/pisysteminfo.h | 5 +++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src_main/system/pisysteminfo.cpp b/src_main/system/pisysteminfo.cpp index bdb07eff..7130cf7a 100644 --- a/src_main/system/pisysteminfo.cpp +++ b/src_main/system/pisysteminfo.cpp @@ -29,6 +29,16 @@ #define SALT_SIZE 8 + + +PISystemInfo::MountInfo::MountInfo() { + space_all = space_used = space_free = 0; + removable = false; +} + + + + PISystemInfo::PISystemInfo() { processorsCount = 1; } @@ -79,12 +89,14 @@ PIStringList PISystemInfo::mountRoots() { struct String3 {PIString mp, type, label;}; -PIVector PISystemInfo::mountInfo() { +PIVector PISystemInfo::mountInfo(bool ignore_cache) { static PIVector cache; static PITimeMeasurer tm; static bool first = true; - if (tm.elapsed_m() < piMountInfoRefreshIntervalMs && !first) - return cache; + if (!ignore_cache) { + if (tm.elapsed_m() < piMountInfoRefreshIntervalMs && !first) + return cache; + } first = false; tm.reset(); cache.clear(); @@ -109,6 +121,8 @@ PIVector PISystemInfo::mountInfo() { m.space_used = m.space_all - m.space_free; } else m.space_all = m.space_free = m.space_used = 0U; + if (GetDriveType(clet.dataAscii()) == DRIVE_REMOVABLE) + m.removable = true; clet.cutRight(1); int qdd = QueryDosDevice(clet.data(), volfs, 1023); if (qdd > 0) diff --git a/src_main/system/pisysteminfo.h b/src_main/system/pisysteminfo.h index a2490a7f..5cab4fc4 100644 --- a/src_main/system/pisysteminfo.h +++ b/src_main/system/pisysteminfo.h @@ -27,7 +27,7 @@ public: PISystemInfo(); struct MountInfo { - MountInfo() {space_all = space_used = space_free = 0;} + MountInfo(); PIString mount_point; PIString device; PIString filesystem; @@ -35,6 +35,7 @@ public: ullong space_all; ullong space_used; ullong space_free; + bool removable; }; PIString ifconfigPath, execCommand, hostname, user, OS_name, OS_version, architecture; @@ -42,7 +43,7 @@ public: int processorsCount; static PIStringList mountRoots(); - static PIVector mountInfo(); + static PIVector mountInfo(bool ignore_cache = false); static PIString machineKey(); static uint machineID();