From 17ab2405fab50497c1f79c8e513fcfdf31979974 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Wed, 10 Mar 2010 12:30:08 +0100 Subject: Add isValid() method to QZipReader::FileInfo. Reviewed-by: Benjamin Poulain --- src/gui/text/qzip.cpp | 7 ++++++- src/gui/text/qzipreader_p.h | 1 + tests/auto/qzip/tst_qzip.cpp | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index fab6891..5aa0a94 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -343,7 +343,7 @@ struct FileHeader }; QZipReader::FileInfo::FileInfo() - : isDir(false), isFile(true), isSymLink(false), crc32(0), size(0) + : isDir(false), isFile(false), isSymLink(false), crc32(0), size(0) { } @@ -368,6 +368,11 @@ QZipReader::FileInfo& QZipReader::FileInfo::operator=(const FileInfo &other) return *this; } +bool QZipReader::FileInfo::isValid() const +{ + return isDir || isFile || isSymLink; +} + class QZipPrivate { public: diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h index d838957..4961e1c 100644 --- a/src/gui/text/qzipreader_p.h +++ b/src/gui/text/qzipreader_p.h @@ -81,6 +81,7 @@ public: FileInfo(const FileInfo &other); ~FileInfo(); FileInfo &operator=(const FileInfo &other); + bool isValid() const; QString filePath; uint isDir : 1; uint isFile : 1; diff --git a/tests/auto/qzip/tst_qzip.cpp b/tests/auto/qzip/tst_qzip.cpp index d7fc2f7..99379b5 100644 --- a/tests/auto/qzip/tst_qzip.cpp +++ b/tests/auto/qzip/tst_qzip.cpp @@ -77,6 +77,7 @@ void tst_QZip::basicUnpack() QCOMPARE(files.count(), 2); QZipReader::FileInfo fi = files.at(0); + QVERIFY(fi.isValid()); QCOMPARE(fi.filePath, QString("test/")); QCOMPARE(uint(fi.isDir), (uint) 1); QCOMPARE(uint(fi.isFile), (uint) 0); @@ -86,6 +87,7 @@ void tst_QZip::basicUnpack() | QFile::ReadUser | QFile::WriteUser | QFile::ExeUser )); fi = files.at(1); + QVERIFY(fi.isValid()); QCOMPARE(fi.filePath, QString("test/test.txt")); QCOMPARE(uint(fi.isDir), (uint) 0); QCOMPARE(uint(fi.isFile), (uint) 1); @@ -104,6 +106,7 @@ void tst_QZip::symlinks() QCOMPARE(files.count(), 2); QZipReader::FileInfo fi = files.at(0); + QVERIFY(fi.isValid()); QCOMPARE(fi.filePath, QString("symlink")); QVERIFY(!fi.isDir); QVERIFY(!fi.isFile); @@ -112,6 +115,7 @@ void tst_QZip::symlinks() QCOMPARE(zip.fileData("symlink"), QByteArray("destination")); fi = files.at(1); + QVERIFY(fi.isValid()); QCOMPARE(fi.filePath, QString("destination")); QVERIFY(!fi.isDir); QVERIFY(fi.isFile); -- cgit v0.12