Thursday, October 19, 2006 4:19 PM
kkchan
VFPCompression from Craig Boyd
Craig Boyd published his VFPCompression.fll, allowed VFP to have "native" compression function. You can get more in details from
here,
here,
here and
here.I have written a wrapper class (prototype) to encapsulate FLL API call into OOP.
******************************
*) ZipFile(cFileName[,lIgnorePath])
******************************
loCompressor.AddFile([c:\abc.txt], .T.)
loCompressor.AddFile([c:\AAA.txt])
llRetVal = loCompressor.Compress([c:\aaa.zip])
******************************
*) ZipFileQuick(cFileName)
******************************
loCompressor.AddFile([c:\abc.txt])
llRetVal = loCompressor.Compress([c:\])
******************************
*) ZipFileRelative(cFileName[,cRelativePath])
******************************
loCompressor.AddFile([c:\abc.txt])
loCompressor.AddFile([c:\AAA.txt], .F., [Capital\test])
llRetVal = loCompressor.Compress([c:\aaaRelative.zip])
******************************
*) : ZipString(cString[, nLevel])
******************************
lcCompressedString = loCompressor.CompressString([my string]
******************************
*) : ZipFolder(cFolderName[,lIgnorePaths])
******************************
loCompressor.AddFolder([c:\zzz])
llRetVal = loCompressor.Compress([c:\zzz.zip])
Craig's VFPCompression API is very simple. Using OOP approach doesn't simplify our job. In fact, it required more typing. The reason of using OOP approach I can think of is scalability. Also, I overloaded compress() method. This compress is called to compress file/quick, folder/quick.
The sample source code posted is only for "preview". I would like to get more feedbacks and comments. Do you think this class is useful? Any suggestions on the class API?Please comment.
Wishlist:
- Zip File Scope - Allow to have multi-session such as FCREATE() and FCLOSE() so that we able to open multiple zip file at the same time.
- Error Message on Failure - Return error message so that we know why the function call failed. It would be perfect if we can use AERROR() to retrieve error info.