Commit c83080ad authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa
Browse files

Do not show the Compressed Size column for 7z archives.

7z archives apparently store only the compressed size for the whole file,
so the values would not be shown correctly in that column.

We now store the archive type when parsing the output from 7z, since the
compressed size values work fine with other archive types 7z is able to
read, such as zip or bzip2.

CCBUG: 236696

svn path=/trunk/KDE/kdeutils/ark/; revision=1142819
parent 75278be8
......@@ -35,6 +35,7 @@ using namespace Kerfuffle;
CliPlugin::CliPlugin(QObject *parent, const QVariantList & args)
: CliInterface(parent, args)
, m_archiveType(ArchiveType7z)
, m_state(ReadStateHeader)
{
}
......@@ -75,7 +76,7 @@ ParameterList CliPlugin::parameterList() const
return p;
}
bool CliPlugin::readListLine(const QString &line)
bool CliPlugin::readListLine(const QString& line)
{
static const QLatin1String archiveInfoDelimiter("----");
static const QLatin1String entryInfoDelimiter("----------");
......@@ -95,7 +96,27 @@ bool CliPlugin::readListLine(const QString &line)
case ReadStateArchiveInformation:
if (line == entryInfoDelimiter) {
m_state = ReadStateEntryInformation;
} else if (line.startsWith(QLatin1String("Type ="))) {
const QString type = line.mid(7).trimmed();
kDebug() << "Archive type: " << type;
if (type == QLatin1String("7z")) {
m_archiveType = ArchiveType7z;
} else if (type == QLatin1String("BZip2")) {
m_archiveType = ArchiveTypeBZip2;
} else if (type == QLatin1String("GZip")) {
m_archiveType = ArchiveTypeGZip;
} else if (type == QLatin1String("Tar")) {
m_archiveType = ArchiveTypeTar;
} else if (type == QLatin1String("Zip")) {
m_archiveType = ArchiveTypeZip;
} else {
// Should not happen
kWarning() << "Unsupported archive type";
return false;
}
}
break;
case ReadStateEntryInformation:
......@@ -108,7 +129,11 @@ bool CliPlugin::readListLine(const QString &line)
} else if (line.startsWith(QLatin1String("Size = "))) {
m_currentArchiveEntry[ Size ] = line.mid(7).trimmed();
} else if (line.startsWith(QLatin1String("Packed Size = "))) {
m_currentArchiveEntry[ CompressedSize ] = line.mid(14).trimmed();
// #236696: 7z files only show a single Packed Size value
// corresponding to the whole archive.
if (m_archiveType != ArchiveType7z) {
m_currentArchiveEntry[CompressedSize] = line.mid(14).trimmed();
}
} else if (line.startsWith(QLatin1String("Modified = "))) {
m_currentArchiveEntry[ Timestamp ] =
QDateTime::fromString(line.mid(11).trimmed(),
......
......@@ -39,12 +39,21 @@ protected:
virtual bool readListLine(const QString &line);
private:
enum ArchiveType {
ArchiveType7z = 0,
ArchiveTypeBZip2,
ArchiveTypeGZip,
ArchiveTypeTar,
ArchiveTypeZip
};
enum ReadState {
ReadStateHeader = 0,
ReadStateArchiveInformation,
ReadStateEntryInformation
};
ArchiveType m_archiveType;
Kerfuffle::ArchiveEntry m_currentArchiveEntry;
ReadState m_state;
};
......
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