SnowCMS Dev Forum
September 06, 2010, 06:16:51 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to become involved with SnowCMS?
 
   Home   Help Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: SGZ - SnowCMS GZip  (Read 220 times)
aldo
Lead Developer
Administrator
Hero Member
*****
Offline Offline

Posts: 501


WWW
« on: February 01, 2010, 02:41:40 AM »

So I needed to make a class of some sort in order to decompress ZIP files, that way when SnowCMS gets updated (later on... Tongue) the system can download the ZIP, extract it, and put the files in the right place.

There was an issue, not all systems have the ZIP plugin enabled for PHP, so I needed to make my own... There was the option of PEAR classes, but the class was 118KB. 118KB just to extract a ZIP? I don't think so Tongue I also thought of making my own ZIP extractor, but I haven't been able to find too much information about that, lol.

So I decided, why not make my own? And I did! I made a class which compresses and extracts what I call an SGZ (SnowCMS GZip, such a cool name, right?). I have compared it to ZIP's and tar.gz's, they are all about the same size Smiley

I have attached the class below, if you want to check it out. I will add how you use it (though you should be able to figure it out by looking at the documents) soon, but I will give a bit of information on how it is structured.

Firstly, SGZ is the first part of the file, just like with a ZIP, it is PK. Then the next 4 bytes contain the number of directories to create, for that length, there will be another 4 bytes which contain the length of the directories name, after that name, there could be another 4 bytes which contain another directory length, unless you have read the specified amount of folders Wink

After that, you will basically have the same setup, but this time with files. So another 4 bytes which contain the number of files which will be extracted. Then, once again, for the amount of files, read 4 bytes which contain the files name length (which contains the path, of course, if any), read that, then another 4 bytes which contain the compressed datas length, read the data, gzinflate it, and put it where it needs to go.

Pretty simple really XD. I might change the structure a bit soon, and I might even change it completely. I was thinking of doing a tarball type setup, but without the tarball crap. With tarball it saves certain file attributes, which I know do have benefits, but when you just want to send multiple files in a single, compressed package, who cares? It certainly won't matter with SnowCMS updates.

Then I suppose there could be two available updates for systems, one which have Zlib enabled ("tarballed" and gzdeflate), and those that don't, so just "tarballed", which would definitely be bigger, but still allow updating without them having to do anything other than clicking "Update!" Smiley
« Last Edit: February 01, 2010, 02:43:48 AM by aldo » Logged
antimatter15
Developer
Sr. Member
*****
Offline Offline

Posts: 299


« Reply #1 on: February 04, 2010, 03:08:42 PM »

Why not a tarball-esque system where you just make the system to merge files and gzdeflate all of it?

I vote not to have it as part of snowcms as packaging would be annoying for developers. And I vote tarball.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.074 seconds with 20 queries.