PDA

View Full Version : paszlib on Linux 64-bit creates empty archive



Christian Knudsen
05-10-2012, 09:47 AM
I'm working on a game where I use paszlib to compress the save files. This works fine on the Windows and Linux setups I've tested it on myself, but a user reported that the game crashed whenever he tried to load a saved file. Some testing revealed that the archives created on his system (Ubuntu 12.04 64-bit) with paszlib are empty -- that is, the zip file is only 122 bytes (which I assume is header information), and when it's uncompressed, the resulting file is 0 bytes.

Here's the relevant code:


PROCEDURE EncodeSaveFile(Const FileName : String);
VAR Zip : TZipper;
BEGIN
Zip := TZipper.Create;
Zip.FileName := 'saves/' + FileName + '.zip';
Zip.Entries.AddFileEntry('saves/' + FileName + '.dat', 'saves/' + FileName + '.dat');
Zip.ZipAllFiles;
Zip.Free;
END;

Some game data files (for example level and map files) are already compressed, and these seem to decompress fine, as the user has no problem playing a level. I'm completely stumped as to what's causing the issue with compression but not decompression. Any ideas?

de_jean_7777
05-10-2012, 10:12 AM
Seems ok. Make sure that AddFileEntry is receiving correct filenames. Check what ('saves/' + FileName + '.dat') gives you and if it matches to a save path/filename. It could be possible that TZipper is not able to read the save file for some reason (like invalid filename).

Christian Knudsen
05-10-2012, 11:00 AM
Yeah, it does seem like TZipper can't read the save file. I've sent an executable that tests the path/file name to the user with the issue.

Christian Knudsen
05-10-2012, 12:43 PM
The report back is that my code can definitely access the .dat file with FileExists(), so that's not it. :(

Christian Knudsen
05-10-2012, 07:10 PM
Man, this sure is weird. His system can compress a file that already exists, but if the code has to create the file first, it doesn't work.


PROGRAM compressiontest;

USES sdl, zipper;

VAR Zip : TZipper;
FileName : String;
SaveFile : Text;
I : Byte;

BEGIN
FileName := '1';
Assign(SaveFile, 'saves/' + FileName + '.dat');
Rewrite(SaveFile);
FOR I := 1 TO 200 DO Writeln(SaveFile, 'HELLO WORLD!');
Flush(SaveFile);
Close(SaveFile);

sdl_delay(500);

Zip := TZipper.Create;
Zip.FileName := 'saves/' + FileName + '.zip';
Zip.Entries.AddFileEntry('saves/' + FileName + '.dat', 'saves/' + FileName + '.dat');
Zip.ZipAllFiles;
Zip.Free;

Assign(SaveFile, 'saves/' + FileName + '.dat');
Erase(SaveFile);
END.

The above code creates saves/1.zip and the zip archive shows the correct size of 1.dat inside it. But unzipping that file shows that its size is 0.

pitfiend
06-10-2012, 07:25 PM
Haven't used TZipper, but can point some things:
- Linux has a case sensitive file system, double check what you save and what you load.
- Be aware that you may have a restricted permission mask over file attributes, you may be expecting -rw-rw-rw- and you are getting anything else.
- Your saving path can be different than your loading path.

Christian Knudsen
08-10-2012, 09:50 AM
So updating the compiler from 2.4.0 to 2.6.0 and also not compiling with any debug information seems to have fixed the issue. Weird.