Improve QFileInfo usage.
Cache QFileInfo result in a local variable. Before repeated request often incorrectly resulted in QString()
This commit is contained in:
parent
4a64465738
commit
d99b3f6eb3
|
@ -104,14 +104,12 @@ FstabEntryList readFstabEntries( const QString& fstabPath )
|
|||
QStringList possibleMountPoints(const QString& deviceNode, const QString& fstabPath)
|
||||
{
|
||||
QStringList mountPoints;
|
||||
QFileInfo kernelPath(deviceNode);
|
||||
QString canonicalPath = kernelPath.canonicalFilePath();
|
||||
QString canonicalPath = QFileInfo(deviceNode).canonicalFilePath();
|
||||
const FstabEntryList fstabEntryList = readFstabEntries( fstabPath );
|
||||
for (const FstabEntry &entry : fstabEntryList) {
|
||||
QFileInfo kernelPath2(entry.deviceNode());
|
||||
if (kernelPath2.canonicalFilePath() == canonicalPath)
|
||||
for (const FstabEntry &entry : fstabEntryList)
|
||||
if (QFileInfo(entry.deviceNode()).canonicalFilePath() == canonicalPath)
|
||||
mountPoints.append(entry.mountPoint());
|
||||
}
|
||||
|
||||
return mountPoints;
|
||||
}
|
||||
|
||||
|
|
|
@ -332,9 +332,10 @@ bool Partition::unmount(Report& report)
|
|||
success = fileSystem().unmount(report, deviceNode());
|
||||
}
|
||||
|
||||
const QString canonicalDeviceNode = QFileInfo(deviceNode()).canonicalFilePath();
|
||||
const QList<QStorageInfo> mountedVolumes = QStorageInfo::mountedVolumes();
|
||||
for (const QStorageInfo &storage : mountedVolumes) {
|
||||
if (QString::fromUtf8(storage.device()) == deviceNode() ) {
|
||||
if (QFileInfo(QString::fromUtf8(storage.device())).canonicalFilePath() == canonicalDeviceNode ) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -135,10 +135,10 @@ QString FileSystem::detectMountPoint(FileSystem* fs, const QString& partitionPat
|
|||
|
||||
QStringList mountPoints;
|
||||
QFileInfo partitionPathFileInfo(partitionPath);
|
||||
QString partitionCanonicalPath = partitionPathFileInfo.canonicalFilePath();
|
||||
const QList<QStorageInfo> mountedVolumes = QStorageInfo::mountedVolumes();
|
||||
for (const QStorageInfo &storage : mountedVolumes) {
|
||||
QFileInfo deviceFileInfo(QString::fromUtf8(storage.device()));
|
||||
if (partitionPathFileInfo.canonicalFilePath() == deviceFileInfo.canonicalFilePath() ) {
|
||||
if (partitionCanonicalPath == QFileInfo(QString::fromUtf8(storage.device())).canonicalFilePath() ) {
|
||||
mountPoints.append(storage.rootPath());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue