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>
This commit is contained in:
Ahmad Samir 2023-10-20 00:09:29 +03:00
parent e34c2429c8
commit b13c46d6ef
2 changed files with 15 additions and 10 deletions

View File

@ -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;
}

View File

@ -67,13 +67,20 @@ public:
QByteArray fsRoot;
dev_t stDev = 0;
};
QStorageInfoPrivate(MountInfo &&info)
: rootPath(std::move(info.mountPoint)),
device(std::move(info.device)),
subvolume(std::move(info.fsRoot)),
fileSystemType(std::move(info.fsType))
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)
{
setFromMountInfo(std::move(info));
}
#elif defined(Q_OS_UNIX)
void initRootPath();
void retrieveVolumeInfo();