Commit 7df03d06 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

archive KIO: no autocast from QString to const char*

GIT_SILENT
parent 0c91f5ef
Pipeline #68885 passed with stage
in 5 minutes and 37 seconds
add_definitions(-DTRANSLATION_DOMAIN=\"kio5_archive\")
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
if(BUILD_TESTING)
add_subdirectory(autotests)
endif()
......
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
add_executable(testkioarchive testkioarchive.cpp)
target_link_libraries(testkioarchive KF5::KIOCore KF5::Archive Qt5::Test)
ecm_mark_as_test(testkioarchive)
......
......@@ -59,19 +59,19 @@ ArchiveProtocol::ArchiveProtocol( const QByteArray &proto, const QByteArray &poo
KArchive *ArchiveProtocol::createArchive( const QString & proto, const QString & archiveFile )
{
if ( proto == "ar" ) {
if ( proto == QLatin1String("ar") ) {
qCDebug(KIO_ARCHIVE_LOG) << "Opening KAr on " << archiveFile;
return new KAr( archiveFile );
}
else if ( proto == "tar" ) {
else if ( proto == QLatin1String("tar") ) {
qCDebug(KIO_ARCHIVE_LOG) << "Opening KTar on " << archiveFile;
return new KTar( archiveFile );
}
else if ( proto == "zip" ) {
else if ( proto == QLatin1String("zip") ) {
qCDebug(KIO_ARCHIVE_LOG) << "Opening KZip on " << archiveFile;
return new KZip( archiveFile );
}
else if ( proto == "sevenz" ) {
else if ( proto == QLatin1String("sevenz") ) {
qCDebug(KIO_ARCHIVE_LOG) << "Opening K7Zip on " << archiveFile;
return new K7Zip( archiveFile );
} else {
......
......@@ -84,14 +84,13 @@ bool ArchiveProtocolBase::checkNewFile( const QUrl & url, QString & path, KIO::E
QString archiveFile;
path.clear();
int len = fullPath.length();
if ( len != 0 && fullPath[ len - 1 ] != '/' )
fullPath += '/';
if (!fullPath.isEmpty() && !fullPath.endsWith(QLatin1Char('/')))
fullPath += QLatin1Char('/');
qCDebug(KIO_ARCHIVE_LOG) << "the full path is" << fullPath;
QT_STATBUF statbuf;
statbuf.st_mode = 0; // be sure to clear the directory bit
while ( (pos=fullPath.indexOf( '/', pos+1 )) != -1 )
while ( (pos=fullPath.indexOf(QLatin1Char('/'), pos+1 )) != -1 )
{
QString tryPath = fullPath.left( pos );
qCDebug(KIO_ARCHIVE_LOG) << fullPath << "trying" << tryPath;
......@@ -128,14 +127,13 @@ bool ArchiveProtocolBase::checkNewFile( const QUrl & url, QString & path, KIO::E
#endif
path = fullPath.mid( pos + 1 );
qCDebug(KIO_ARCHIVE_LOG).nospace() << "fullPath=" << fullPath << " path=" << path;
len = path.length();
if ( len > 1 )
if ( path.length() > 1 )
{
if ( path[ len - 1 ] == '/' )
path.truncate( len - 1 );
if (path.endsWith(QLatin1Char('/')))
path.chop(1);
}
else
path = QString::fromLatin1("/");
path = QStringLiteral("/");
qCDebug(KIO_ARCHIVE_LOG).nospace() << "Found. archiveFile=" << archiveFile << " path=" << path;
break;
}
......@@ -227,7 +225,7 @@ void ArchiveProtocolBase::createRootUDSEntry( KIO::UDSEntry & entry )
auto path = m_archiveFile->fileName();
path = path.mid(path.lastIndexOf(QLatin1Char('/')) + 1);
entry.fastInsert( KIO::UDSEntry::UDS_NAME, "." );
entry.fastInsert( KIO::UDSEntry::UDS_NAME, QStringLiteral(".") );
entry.fastInsert( KIO::UDSEntry::UDS_DISPLAY_NAME, path );
entry.fastInsert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR );
entry.fastInsert( KIO::UDSEntry::UDS_MODIFICATION_TIME, m_mtime );
......@@ -298,7 +296,7 @@ void ArchiveProtocolBase::listDir( const QUrl & url )
QUrl redir;
redir.setScheme(url.scheme());
qCDebug(KIO_ARCHIVE_LOG) << "url.path()=" << url.path();
redir.setPath( url.path() + QString::fromLatin1("/") );
redir.setPath( url.path() + QLatin1Char('/') );
qCDebug(KIO_ARCHIVE_LOG) << "redirection" << redir.url();
redirection( redir );
finished();
......@@ -308,7 +306,7 @@ void ArchiveProtocolBase::listDir( const QUrl & url )
qCDebug(KIO_ARCHIVE_LOG) << "checkNewFile done";
const KArchiveDirectory* root = m_archiveFile->directory();
const KArchiveDirectory* dir;
if (!path.isEmpty() && path != "/")
if (!path.isEmpty() && path != QLatin1String("/"))
{
qCDebug(KIO_ARCHIVE_LOG) << "Looking for entry" << path;
const KArchiveEntry* e = root->entry( path );
......@@ -331,7 +329,7 @@ void ArchiveProtocolBase::listDir( const QUrl & url )
totalSize( l.count() );
UDSEntry entry;
if (!l.contains(".")) {
if (!l.contains(QLatin1String("."))) {
createRootUDSEntry(entry);
listEntry(entry);
}
......@@ -411,7 +409,7 @@ void ArchiveProtocolBase::stat( const QUrl & url )
const KArchiveEntry* archiveEntry;
if ( path.isEmpty() )
{
path = QString::fromLatin1( "/" );
path = QStringLiteral("/");
archiveEntry = root;
} else {
archiveEntry = root->entry( path );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment