DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:compression

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
devel:compression [2013-05-04 14:52] – created Klap-indevel:compression [2015-08-05 19:09] (current) – removed andi
Line 1: Line 1:
-====== Compression/decompression ====== 
  
-DokuWiki contains two classes to provide compression and extracting functions. These support gzip, bzip, tar and zip formats. 
- 
-Please refer to the [[xref>Tar]] and the [[xref>ZipLib]] class documentation for implementation details. 
- 
-FIXME explain long pathnames in posix ustar and gnu longlink formats,  
- 
-=====Tar archives===== 
- 
-The [[xref>Tar]] class allows the extraction of existing and the creation of new Unix TAR archives. 
-To keep things simple, the modification of existing archives is not supported. It handles 
-uncompressed, gzip and bzip2 compressed tar files. 
- 
-Long pathnames (>100 chars) are supported in POSIX ustar and GNU longlink formats. 
- 
-To list the contents of an existing TAR archive, ''open()'' it and use ''contents()'' on it: 
-<code php> 
-$tar = new Tar(); 
-$tar->open('myfile.tgz'); 
-$toc = $tar->contents(); 
-print_r($toc); 
-</code> 
- 
-To extract the contents of an existing TAR archive, ''open()'' it and use ''extract()'' on it: 
-<code php> 
-$tar = new Tar(); 
-$tar->open('myfile.tgz'); 
-$tar->extract('/tmp'); 
-</code> 
- 
-To create a new TAR archive directly on the filesystem (low memory requirements), ''create()'' it, 
-''add*()'' files and ''close()'' it: 
-<code php> 
-$tar = new Tar(); 
-$tar->create('myfile.tgz'); 
-$tar->addFile('/filesystem/dir/folder/mytestfile.txt'); 
-$tar->addFile(,'/filesystem/dir/mytestfile2.txt', 'anotherdir/mytestfile2.txt');  
-$tar->addData('anotherdir/mytestfile.txt', 'This string is content'); 
-... 
-$tar->close(); 
-</code> 
- 
-To create a TAR archive directly in memory, ''create()'' it, ''add*()'' files and then either ''save()'' 
-or ''getData()'' it: 
-<code php> 
-$tar = new Tar(); 
-$tar->create(); 
-$tar->addFile(...); 
-$tar->addData(...); 
-... 
-$tar->save('myfile.tgz'); // compresses and saves it 
-echo $tar->getArchive(Tar::COMPRESS_GZIP); // compresses and returns it 
-</code> 
- 
-====Deprecated TarLib==== 
-[[deprecated]] 
- 
-Before the ''Tar'' class Dokuwiki included the ''TarLib'' class. Now TarLib is only a compatibility wrapper around the new Tar class for the extraction function. Please update your code by implementing the Tar class when you still use the TarLib class in your code. 
- 
- 
-=====Zip archives===== 
- 
-To list the contents of an existing ZIP archive, use ''get_List()'' on it: 
-<code php> 
-$zip = new ZipLib(); 
-$toc = $zip->get_List('myfile.zip'); 
-print_r($toc); 
-</code> 
- 
-To extract the contents of an existing ZIP archive, use ''Extract()'' on it: 
-<code php> 
-$zip = new ZipLib(); 
-$ok  = $zip->Extract('myfile.zip', '/tmp'); 
-</code> 
- 
-To create a new ZIP archive of files, ''Add()'' the files and return it: 
-<code php> 
-$zip = new ZipLib(); 
-$successarray = $zip->Add(..., true); //add files with compression on) 
-$successarray = $zip->Add(..., true); 
-... 
-echo $zip->get_file(); //returns the Zip file 
-</code> 
- 
-To create a new ZIP archive of a folder, ''Compress()'' the folder and return it: 
-<code php> 
-$zip = new ZipLib(); 
-//Zips recursively the $folder directory, from the $basedir directory 
-$zip->Compress($folder, $basedir=null, $parent=null);  
-... 
-echo $zip->get_file(); //returns the Zip file 
-</code> 
- 
-=====Example of application===== 
-The Plugin manager applies this libraries to perform the extracting of downloads. 
- 
-See [[xref>decompress]] method for an example implementation. 
devel/compression.1367671942.txt.gz · Last modified: 2013-05-04 14:52 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki