From kde-commits Tue Dec 01 11:45:46 2009 From: Thomas McGuire Date: Tue, 01 Dec 2009 11:45:46 +0000 To: kde-commits Subject: branches/KDE/3.5/kdelibs/kio/kio Message-Id: <1259667946.595523.20214.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=125966795232474 SVN commit 1057062 by tmcguire: Support writing empty directories to ZIP files. M +12 -1 kzip.cpp M +1 -4 kzip.h --- branches/KDE/3.5/kdelibs/kio/kio/kzip.cpp #1057061:1057062 @@ -1051,6 +1051,17 @@ return true; } +bool KZip::writeDir(const QString& name, const QString& user, const QString& group) +{ + // Zip files have no explicit directories, they are implicitly created during extraction time + // when file entries have paths in them. + // However, to support empty directories, we must create a dummy file entry which ends with '/'. + QString dirName = name; + if (!name.endsWith("/")) + dirName = dirName.append('/'); + return writeFile(dirName, user, group, 0, 0); +} + // Doesn't need to be reimplemented anymore. Remove for KDE-4.0 bool KZip::writeFile( const QString& name, const QString& user, const QString& group, uint size, const char* data ) { @@ -1114,7 +1125,7 @@ } // delete entries in the filelist with the same filename as the one we want - // to save, so that we don´t have duplicate file entries when viewing the zip + // to save, so that we don�t have duplicate file entries when viewing the zip // with konqi... // CAUTION: the old file itself is still in the zip and won't be removed !!! QPtrListIterator it( d->m_fileList ); --- branches/KDE/3.5/kdelibs/kio/kio/kzip.h #1057061:1057062 @@ -191,10 +191,7 @@ /// Closes the archive virtual bool closeArchive(); - /** - * @internal Not needed for zip - */ - virtual bool writeDir( const QString& name, const QString& user, const QString& group) { Q_UNUSED(name); Q_UNUSED(user); Q_UNUSED(group); return true; } + virtual bool writeDir(const QString& name, const QString& user, const QString& group); // TODO(BIC) uncomment and make virtual for KDE 4. // bool writeDir( const QString& name, const QString& user, const QString& group, // mode_t perm, time_t atime, time_t mtime, time_t ctime );