summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-10-20 00:09:29 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-11-04 16:46:05 +0200
commitb13c46d6ef6003c267c976942db05cdaec0a6f75 (patch)
tree393b2745592ae4110fa844b37aab8924213810b5
parente34c2429c8d6b702570eff846d639df12fc94d0d (diff)
QStorageInfoPrivate/Linux: de-duplicate some code
Change-Id: Ie0fe0c80a61c123c12242f24830ca622a726d7ac Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/io/qstorageinfo_linux.cpp8
-rw-r--r--src/corelib/io/qstorageinfo_p.h15
2 files changed, 14 insertions, 9 deletions
diff --git a/src/corelib/io/qstorageinfo_linux.cpp b/src/corelib/io/qstorageinfo_linux.cpp
index e1f7fe65ac..40e3cafd5a 100644
--- a/src/corelib/io/qstorageinfo_linux.cpp
+++ b/src/corelib/io/qstorageinfo_linux.cpp
@@ -229,11 +229,9 @@ quint64 QStorageInfoPrivate::initRootPath()
for (auto it = infos.rbegin(); it != infos.rend(); ++it) {
if (rootPathDevId != it->stDev || !isParentOf(it->mountPoint, oldRootPath))
continue;
- rootPath = std::move(it->mountPoint);
- device = std::move(it->device);
- fileSystemType = std::move(it->fsType);
- subvolume = std::move(it->fsRoot);
- return it->stDev;
+ auto stDev = it->stDev;
+ setFromMountInfo(std::move(*it));
+ return stDev;
}
return 0;
}
diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h
index 9b3b52d859..e133c20cb4 100644
--- a/src/corelib/io/qstorageinfo_p.h
+++ b/src/corelib/io/qstorageinfo_p.h
@@ -67,13 +67,20 @@ public:
QByteArray fsRoot;
dev_t stDev = 0;
};
+
+ void setFromMountInfo(MountInfo &&info)
+ {
+ rootPath = std::move(info.mountPoint);
+ fileSystemType = std::move(info.fsType);
+ device = std::move(info.device);
+ subvolume = std::move(info.fsRoot);
+ }
+
QStorageInfoPrivate(MountInfo &&info)
- : rootPath(std::move(info.mountPoint)),
- device(std::move(info.device)),
- subvolume(std::move(info.fsRoot)),
- fileSystemType(std::move(info.fsType))
{
+ setFromMountInfo(std::move(info));
}
+
#elif defined(Q_OS_UNIX)
void initRootPath();
void retrieveVolumeInfo();