QFSFileEngine::filename(): convert if/else-if chain to a switch
Makes clear that this is what it is; and ensures we'll get compiler warnings if someone adds a new entry to the FileName enum without code to handle it here. Change-Id: I36e383066728cefcc75e0a760e36222cebd1dff0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
a76a0afc1a
commit
ed79462d99
@ -530,29 +530,32 @@ QByteArray QFSFileEngine::id() const
|
|||||||
QString QFSFileEngine::fileName(FileName file) const
|
QString QFSFileEngine::fileName(FileName file) const
|
||||||
{
|
{
|
||||||
Q_D(const QFSFileEngine);
|
Q_D(const QFSFileEngine);
|
||||||
if (file == BundleName) {
|
switch (file) {
|
||||||
|
case BundleName:
|
||||||
return QFileSystemEngine::bundleName(d->fileEntry);
|
return QFileSystemEngine::bundleName(d->fileEntry);
|
||||||
} else if (file == BaseName) {
|
case BaseName:
|
||||||
return d->fileEntry.fileName();
|
return d->fileEntry.fileName();
|
||||||
} else if (file == PathName) {
|
case PathName:
|
||||||
return d->fileEntry.path();
|
return d->fileEntry.path();
|
||||||
} else if (file == AbsoluteName || file == AbsolutePathName) {
|
case AbsoluteName:
|
||||||
|
case AbsolutePathName: {
|
||||||
QFileSystemEntry entry(QFileSystemEngine::absoluteName(d->fileEntry));
|
QFileSystemEntry entry(QFileSystemEngine::absoluteName(d->fileEntry));
|
||||||
if (file == AbsolutePathName) {
|
return file == AbsolutePathName ? entry.path() : entry.filePath();
|
||||||
return entry.path();
|
|
||||||
}
|
}
|
||||||
return entry.filePath();
|
case CanonicalName:
|
||||||
} else if (file == CanonicalName || file == CanonicalPathName) {
|
case CanonicalPathName: {
|
||||||
QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry, d->metaData));
|
QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry, d->metaData));
|
||||||
if (file == CanonicalPathName)
|
return file == CanonicalPathName ? entry.path() : entry.filePath();
|
||||||
return entry.path();
|
}
|
||||||
return entry.filePath();
|
case LinkName:
|
||||||
} else if (file == LinkName) {
|
|
||||||
if (d->isSymlink()) {
|
if (d->isSymlink()) {
|
||||||
QFileSystemEntry entry = QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData);
|
QFileSystemEntry entry = QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData);
|
||||||
return entry.filePath();
|
return entry.filePath();
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
|
case DefaultName:
|
||||||
|
case NFileNames:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return d->fileEntry.filePath();
|
return d->fileEntry.filePath();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user