Print Topic - Archive

XBLite Forum  /  Working Code Snippets  /  Simple filesystem using compressed archives
Posted by: 26 (Guest), September 8, 2008, 7:54am
I am still working to (re)build my toolkit and i wrote a simple filesystem.It allow writting compressed/uncompressed files and reading files in compressed/uncompressed archives.

I noticed zlib example on http://www.xblite.com page has problems because functions are declared as CCALL functions and zlibwapi.dll functions are STDCALL functions, i had serious headaches before finding what was wrong.I inclued updated header file,lib and zlib 1.2.3 dll in the package.

It seems free of bugs but if you find some, mail me ;)
The only problem is opening a file that is not in an archive is slow because zlib owns no function to find uncompressed file size.If someone finds a better solution than mine, i'll be happy.

This is extracted from readme.txt :

Quoted Text
This is a file simple file system that allows to mount archives in TAR/TAR.GZ format and read in them transparently
It is is totaly recursive so you can mount nested archives (russian dolls :D)
My first idea was to implement that with ZIP format but there are too much differents versions and compressions and
some ZIP programs create weird zip files.TAR/TAR.GZ if enough for me ;)

It comes in 2 flavors : winapi & zlib version.

The winapi version allows TAR archives files mounting, linear reading and writting.
The zlib version allows TAR and TAR.GZ archives, .GZ files transparent reading (you read it same way you read a
non-compressed file) and compressed or linear writting.

TAR / TAR.GZ / GZ archive format is widely used ad there are a lot of tools to build thems.This is the one is use :
ALzip : http://www.altools.com/ALTools/ALZip.aspx
Posted by: Rhett Thompson, September 8, 2008, 12:36pm; Reply: 1
Hi,

You might want to check out the 7zip SDK.  I think it handles all of the discrepancies between different ZIP files, as well as support other compression algorithms(e.g. RAR, BZIP, etc.).  Anyhow, great work on this! I haven't found any bugs either:)
Posted by: 26 (Guest), September 14, 2008, 2:16pm; Reply: 2
Thanks Rhett, i took a look to 7zip Sdk, it is very interessant but will take time to adapt to XBlite because it is COM interface.I'll surely study it more in details after my current project.
I improved FS (slow open func fixed and added handler check w/ signature) and i will surely improve it more because it is used in my current project (a complete 2D game).I'll post it later with the project source ;)
Posted by: 17 (Guest), September 19, 2008, 3:10am; Reply: 3
Hi Fano,

Rhett already suggested to handle a COM interface by:
1. writing function wrappers with c++ in a library (.dll)
2. exposing the wrappers' interface by declaring their prototypes extern "C"

I did not try it but Rhett might have.

Bye! Guy
Posted by: Rhett Thompson, September 19, 2008, 1:25pm; Reply: 4
Hi,

Guy is right is should be a fairly trivial thing to write a simple wrapper for the 7zip SDK.  Although I haven't written one for 7zip, I have for much more complex libraries (HGE and Irrlicht), and and the API does look simple.

The concept is simple enough:

You basically write a "constructor" wrapper function, around the actual constructor in C++ like:

Code
void*hge_Create(params...){

   return new hge(params...);

}


Then to access the methods of the object, you would write a wrapper for each method:

Code
void hge_setWindowSize(hge*hge, unsigned int width, unsigned int height){
   
   hge->setWindowSize(width, height);

}


Although the code does pile up after a bit, it works:)
Posted by: 26 (Guest), September 21, 2008, 9:46am; Reply: 5
Thanks for the tips, i think i'll look more further in 7zip because it seems a great library so i'll take some time to study it.
Print page generated: November 24, 2017, 1:47am