ErosOlmi
29-01-2012, 12:59
Next thinBasic will have a set of new functions inside zLib module able to handle ZIP files.
So far I've added the following:
ZLib_Version
ZLib_AddToZip(File, ZipFile)
ZLib_ListFiles(ZipFile)
ZLib_AddToZipEx(File, ZipFile, Flags)
ZLib_FindFile(File, ZipFile)
ZLib_ExtractFromZip(ZipFile, OutputDir)
I'm still working on those functions (and also working on understanding zLib library) so maybe the syntax will change for some of them.
Ciao
Eros
Petr Schreiber
29-01-2012, 19:32
Eros,
this is looking great.
I have a one note - in line with FILE module syntax, I would expect the ZipFile to be always the first parameter in the procedural interface, making it:
ZLib_Version
ZLib_AddToZip(ZipFile, File) ' -- Analogy to File_Copy(what, where)
ZLib_ListFiles(ZipFile)
ZLib_AddToZipEx(ZipFile, File, Flags)
ZLib_FindFile(ZipFile, File)
ZLib_ExtractFromZip(ZipFile, OutputDir)
I have heretic idea about ZIPFile class, which could eliminate the need to pass ZipFile as first parameter again and again.
For OOP interface, the constructor would take optionally the parameter of ZipFile. Then the further operations would not need that:
ZIPFile z = new ZIPFile(App_SourcePath + "my.zip")
z.File = APP_SourcePath ' -- Changing the handled file via property, for example if I didn't pass it to the constructor
z.AddFile(File) ' -- the same as ZLib_AddToZip
z.AddFile(File, Flags) ' -- the same as ZLib_AddToZipEx
z.ListFiles( array() ) or sBuffer = z.ListFiles() ' -- the same as ZLib_ListFiles
z.FindFile(File) ' -- the same asZLib_FindFile, here I am not sure what this returns?
z.Extract(OutputDir) ' -- the same as ZLib_ExtractFromZip
z.Extract(OutputDir, FileFromZIP) ' -- the same as ZLib_ExtractFromZip, except it will extract only specified file
z.Extract(OutputDir, FilesFromZIP) ' -- the same as ZLib_ExtractFromZip, except it will extract only specified files in passed array
You can see the OOP syntax adds lot of clarity - we manipulate ZIPFile instance, so no need to add that to name of method + the path to file is assigned once and then held.
Petr
ErosOlmi
29-01-2012, 19:56
My Yes for putting ZipFile as first parameter.
My Yes for also adding a module class, but I have to think about it because zLib library is very C style oriented and not easy to transform into a class.
Ciao
Eros