use MDV::Packdrakeng; # creating an archive $pack = MDV::Packdrakeng->new(archive => "myarchive.cz"); # Adding a few files $pack->add("/path/", "file1", "file2"); # Adding an unamed file open($handle, "file"); $pack->add_virtual("filename", $handle); close($handle); $pack = undef; # extracting an archive $pack = MDV::Packdrakeng->open(archive => "myarchive.cz"); # listing files $pack->list(); # extracting few files $pack->extract("/path/", "file1", "file2"); # extracting data into a file handle open($handle, "file"); $pack->extract_virtual($handle, "filename"); close($handle);
UncompresseddatA1UncompresseddatA2 UncompresseddatA3UncompresseddatA4 |--- size 1 ---||--- size 2 ---| |--- size 3 ---||--- size 4 ---| |<-offset1 |<-offset2 |<-offset3 |<-offset4
gives:
CompresseD1CompresseD2 CompresseD3CompresseD4 |--- c. size 1, 2 ---| |--- c. size 3, 4 ---| |<-c. offset 1, 2 |<-c. offset 3, 4
A new block is started when its size exceeds the "block_size" value.
Compressed data are followed by the table of contents (toc), that is, a simple list of packed files. Each file name is terminated by the "\n" character:
dir1 dir2 ... dirN symlink1 point_file1 symlink2 point_file2 ... ... symlinkN point_fileN file1 file2 ... fileN
The file sizes follows, 4 values are stored for each file: offset into archive of compressed block, size of compressed block, offset into block of the file and the file's size.
Finally the archive contains a 64-byte trailer, about the toc and the archive itself:
'cz[0', strings 4 bytes number of directory, 4 bytes number of symlinks, 4 bytes number of files, 4 bytes the toc size, 4 bytes the uncompression command, string of 40 bytes length '0]cz', string 4 bytes
The uncompression command is found into the archive, and the compression command is deduced from it.
If you add files, a new compressed block will be started even if the last block is smaller than the value of the "block_size" option. If some compression options can't be found in the archive, the new preference will be applied.
Options are the same than for the "new()" function.
- 'd', the file will be a directory, store as '$filename'. $data is not used. - 'l', the file will be a symlink named $filename, pointing to the file whose path is given by the string $data. - 'f', the file is a normal file, $filename will be its name, $data is either an handle to open file, data will be read from current position to the end of file, either a string to push as the content of the file.
- 'f' and the the size of the file for a plain file - 'l' and the linked file for a symlink - 'd' and undef for a directory - undef if the file can't be found into archive.
Copyright (c) 2005 Mandriva
This module is a from scratch-rewrite of the original "packdrake" utility. Its format is fully compatible with the old packdrake.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
If you do not have a copy of the GNU General Public License write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.