Changeset View
Changeset View
Standalone View
Standalone View
man/kio_man.cpp
Show First 20 Lines • Show All 561 Lines • ▼ Show 20 Line(s) | 555 | { | |||
---|---|---|---|---|---|
562 | 562 | | |||
563 | lastdir = filename.left(filename.lastIndexOf('/')); | 563 | lastdir = filename.left(filename.lastIndexOf('/')); | ||
564 | 564 | | |||
565 | // get the last directory name (which might be a language name, to be able to guess the encoding) | 565 | // get the last directory name (which might be a language name, to be able to guess the encoding) | ||
566 | QDir dir(lastdir); | 566 | QDir dir(lastdir); | ||
567 | dir.cdUp(); | 567 | dir.cdUp(); | ||
568 | dirName = QFile::encodeName(dir.dirName()); | 568 | dirName = QFile::encodeName(dir.dirName()); | ||
569 | 569 | | |||
570 | if ( !QFile::exists(QFile::decodeName(filename)) ) // if given file does not exist, find with suffix | 570 | if ( !QFile::exists(QFile::decodeName(filename)) ) // if given file does not exist, find with suffix | ||
apol: mark `const`. | |||||
571 | { | 571 | { | ||
572 | qCDebug(KIO_MAN_LOG) << "not existing " << filename; | 572 | qCDebug(KIO_MAN_LOG) << "not existing " << filename; | ||
573 | QDir mandir(lastdir); | 573 | QDir mandir(lastdir); | ||
574 | mandir.setNameFilters(QStringList() << (filename.mid(filename.lastIndexOf('/') + 1) + ".*")); | 574 | const QString nameFilter = filename.mid(filename.lastIndexOf('/') + 1) + ".*"; | ||
575 | filename = lastdir + '/' + QFile::encodeName(mandir.entryList().first()); | 575 | mandir.setNameFilters(QStringList(nameFilter)); | ||
576 | | ||||
577 | const QStringList entries = mandir.entryList(); | ||||
578 | if (entries.isEmpty()) | ||||
579 | { | ||||
580 | outputError(i18n("The specified man page referenced another page '%1',<br />" | ||||
581 | "but the referenced page '%2' could not be found.", | ||||
582 | QFile::decodeName(filename), | ||||
583 | QDir::cleanPath(lastdir + '/' + nameFilter))); | ||||
584 | return 0; | ||||
585 | } | ||||
586 | | ||||
587 | filename = lastdir + '/' + QFile::encodeName(entries.first()); | ||||
576 | qCDebug(KIO_MAN_LOG) << "resolved to " << filename; | 588 | qCDebug(KIO_MAN_LOG) << "resolved to " << filename; | ||
577 | } | 589 | } | ||
578 | 590 | | |||
579 | KFilterDev fd(QFile::encodeName(filename)); | 591 | KFilterDev fd(QFile::encodeName(filename)); | ||
580 | 592 | | |||
581 | if ( !fd.open(QIODevice::ReadOnly)) | 593 | if ( !fd.open(QIODevice::ReadOnly)) | ||
582 | return nullptr; | 594 | return nullptr; | ||
583 | 595 | | |||
▲ Show 20 Lines • Show All 830 Lines • Show Last 20 Lines |
mark const.