Posted: Tue May 16, 2006 8:55 am
Hmm... just had a look at the code, and I can't really see how to do this differently, and I also tried to compare the listings of a "regular" .zip file and one created with bsppack, and they both look identical to me (both have entries for folders as well, and not only files) I guess the directory entries could, in principal, be removed, but if I remember correctly, I tried this and it doesn't work.
This is the actual function that compresses the files...
oh, and to you coders, before you say anything, I know, I know, big no no to have files as a classglobal variable I was still learning code design when writing this then again, I still am
Then again, if windows explorer is the only program that fucks up, I'm very prone to write this off as a windows explorer problem. (I trust winzip and unzip more than windows explorer any day )
This is the actual function that compresses the files...
oh, and to you coders, before you say anything, I know, I know, big no no to have files as a classglobal variable I was still learning code design when writing this then again, I still am
Code: Select all
protected void compressFiles(File zip) throws IOException
{
ZipOutputStream zo = new ZipOutputStream(new FileOutputStream(zip));
for (int i = 0; i<files.size(); i++)
{
byte b[] = new byte[512];
FileHolder fh = (FileHolder) files.get(i);
fh.setName(fh.getName().replace(File.separatorChar, '/'));
/* NOTE!!!!! it seems as if linux doesn't search for the correct cased names after
* all, but tried to find the lower case versions of the needed files... therefore,
* the .toLowerCase() will make sure that the all files in the .zip are in lowercase...
*/
ZipEntry ze = new ZipEntry(fh.getName().toLowerCase());
zo.putNextEntry(ze);
if (!ze.isDirectory())
{
int len = 0;
try
{
InputStream in = new FileInputStream(fh.getFile());
while ((len = in.read(b)) != -1)
{
zo.write(b,0,len);
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
zo.closeEntry();
if (ze.getSize() > 0) sysout.print("Deflated ("+((ze.getCompressedSize()*100)/ze.getSize())+"%):\t"+fh.getName()+"...");
}
zo.close();
sysout.print("Done...");
}