File archives on Windows CE (and all other platforms probably)
Network traffic on a Windows CE device is usually either slow (Bluetooth) or expensive (GPRS, UMTS), so it makes sense to compress and data on it's way to or from the device.
The data I had in mind were program updates, and seeing that on Windows CE the .cab file format is used even for installers, I first thought using this method provided by Microsoft would be the best and smallest method. But sadly, I couldn't find a cabinet.dll on the actual device after having tried to port to existing cab libraries and writing my own interface for that dynamic link library.
So naturally, I looked at what FreePascal and Lazarus had to offer - there were examples for bzip2 and gzip, for example. I couldn't really get both to work though, so I came back to something I tried earlier, but discarded then because of a 32K limit problem: TCompressionStream and TDecompressionStream, which use the paszlib package.
The 32K problem was just a temporary one, and testing showed these classes are compatible between Win32 and WinCE, so I wrote a small unit, ceZStreams.pas, which includes two small functions to compress and extract multiple files into/from one archive. It still needs some error handling (checking the MD5s previously stored) as well as standard features (storing and restoring file dates, paths, listing only instead of extracting, etc.), but it comes with a very simple directory structure that makes it easy to be enhanced without loosing backward compatibility.

0 Comments:
Post a Comment
<< Home