[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Patch for KZip in kio
From: Stefan Gehn <sgehn () gmx ! net>
Date: 2003-01-10 16:26:41
[Download RAW message or body]
Moin,
because the maintainer did not answer to my mail including a nice patch (sent
on dec 27th 2002) I'll post it here now :)
Here's the original mail I sent:
-------------------------------------------------------------------
I frequently got annoyed by zipfiles with their directories shown twice and no
files in them. I debugged it some more and it seems to come from this
difference (unzip -l listing of two files):
CORRECT:
Length Date Time Name
------- ---- ---- ----
0 12-27-02 12:28 ordner/unterordner2/
4656012 12-22-02 18:39 ordner/unterordner2/p3b-f-104.pdf
44605 12-06-02 10:33 ordner/unterordner2/tcpdump_no_answer.txt
WRONG:
Length Date Time Name
------- ---- ---- ----
237 11-22-02 10:46 System/Manga.upl
0 11-22-02 10:50 System/
428606 11-22-02 10:46 Animations/MangaB.ukx
0 11-22-02 10:51 Animations/
As you can see the files come before the directory-entry in the listing. This
seems to be a weirdness by some zip-archiver on windows, probably maybe even
the very well known WinZip. Midnight Commander had the same problem in
earlier versions btw :)
Attached is a patch doing the following:
if entry is a dir first check if we already have it appended, if yes set entry
to 0L which later results in not appending any entry at all.
For broken ZIPs the dir-entries then get added by the findOrCreate()-call some
lines below.
I tested this with a selfmade ZIP and different downloaded ZIPs (windows and
unix downloads) and it worked fine for me.
Bye, Stefan aka mETz
--
sgehn_AT_gmx.net | ICQ#51123152 | Moege der Pinguin mit euch sein
["kzip.patch" (text/x-diff)]
Index: kzip.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kio/kzip.cpp,v
retrieving revision 1.25
diff -u -3 -p -r1.25 kzip.cpp
--- kzip.cpp 21 Dec 2002 09:53:25 -0000 1.25
+++ kzip.cpp 27 Dec 2002 13:56:37 -0000
@@ -331,27 +331,43 @@ bool KZip::openArchive( int mode )
KArchiveEntry* entry;
if ( isdir )
- entry = new KArchiveDirectory( this, entryName, access, time, \
rootDir()->user(), rootDir()->group(), QString::null ); + {
+ QString path = QDir::cleanDirPath( name.left( pos ) );
+ KArchiveEntry* ent = rootDir()->entry( path );
+ if ( ent && ent->isDirectory() )
+ {
+ //kdDebug(7040) << "Directory already exists, NOT going to add \
it again" << endl; + entry = 0L;
+ }
+ else
+ {
+ entry = new KArchiveDirectory( this, entryName, access, time, \
rootDir()->user(), rootDir()->group(), QString::null ); + \
//kdDebug(7040) << "KArchiveDirectory created, entryName= " << entryName << ", name=" \
<< name << endl; + }
+ }
else
{
entry = new KZipFileEntry( this, entryName, access, time, \
rootDir()->user(), rootDir()->group(), QString::null,
- name, dataoffset, ucsize, cmethod, csize \
); + name, dataoffset, ucsize, cmethod, csize \
);
static_cast<KZipFileEntry *>(entry)->setHeaderStart( \
localheaderoffset );
- //kdDebug(7040) << "KZipFileEntry created" << endl;
+ //kdDebug(7040) << "KZipFileEntry created, entryName= " << entryName \
<< ", name=" << name << endl;
d->m_fileList.append( static_cast<KZipFileEntry *>( entry ) );
}
- if ( pos == -1 )
+ if ( entry )
{
- rootDir()->addEntry(entry);
- }
- else
- {
- // In some tar files we can find dir/./file => call cleanDirPath
- QString path = QDir::cleanDirPath( name.left( pos ) );
- // Ensure container directory exists, create otherwise
- KArchiveDirectory * tdir = findOrCreate( path );
- tdir->addEntry(entry);
+ if ( pos == -1 )
+ {
+ rootDir()->addEntry(entry);
+ }
+ else
+ {
+ // In some tar files we can find dir/./file => call cleanDirPath
+ QString path = QDir::cleanDirPath( name.left( pos ) );
+ // Ensure container directory exists, create otherwise
+ KArchiveDirectory * tdir = findOrCreate( path );
+ tdir->addEntry(entry);
+ }
}
//calculate offset to next entry
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic