MDV::Packdrakeng(3)
π MDV::Packdrakeng π
okay bestie, sit down, we're learning MDV::Packdrakeng β it's a Simple Archive Extractor/Builder and it lives in the User Contributed Perl Documentation section of your man pages, under the name MDV::Packdrakeng(3). she's giving very much "quiet library module that just works" energy and honestly? obsessed.
β¨ SYNOPSIS β¨
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);
like. look at that. build a thing, yeet some files in, close it, open it back up, pull stuff out. that's the whole vibe fr fr πΈ
π¦ DESCRIPTION π¦
MDV::Packdrakeng is a simple indexed archive builder and extractor using standard compression methods. that's it, that's the girl. she builds, she extracts, she uses compression like every other normal archiver, no drama, no cap.
π IMPLEMENTATION π
okay this is the part where it gets juicy. compressed data are stored by block. so picture this:
UncompresseddatA1UncompresseddatA2 UncompresseddatA3UncompresseddatA4
|--- size 1 ---||--- size 2 ---| |--- size 3 ---||--- size 4 ---|
|<-offset1 |<-offset2 |<-offset3 |<-offset4
and that lil arrangement gives you:
CompresseD1CompresseD2 CompresseD3CompresseD4
|--- c. size 1, 2 ---| |--- c. size 3, 4 ---|
|<-c. offset 1, 2 |<-c. offset 3, 4
so basically multiple uncompressed things get smooshed into one compressed block, and the offsets do the bookkeeping. a new block is started when its size exceeds the block_size value. periodt. π
then, the compressed data are followed by the table of contents (toc), which is just a simple list of packed files. every file name is terminated by the "\n" character:
dir1
dir2
...
dirN
symlink1
point_file1
symlink2
point_file2
...
...
symlinkN
point_fileN
file1
file2
...
fileN
then comes the file sizes β and heads up, 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. four things. per file. every file. she's thorough like that. π
finally, the archive contains a 64-byte trailer with info 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
π FUNCTIONS π
π new(%options)
creates a new archive. brand new baby archive, freshly born. π«Ά options are:
archiveβ the file name of the archive. if the file doesn't exist, it will be created; else it will be owerwritten. yeah. overwritten. say bye to whatever was there. see"open".compressβ the application to use to compress. if unspecified,gzipis used.uncompressβ the application used to extract data from archive. this option is useless if you're opening an existing archive (unless you want to force it, main character move). if unset, this value is based on the compress command followed by the-dargument.externβ if you're usinggzip, by default MDV::Packdrakeng will use perl-zlib to save system ressources. this option forces MDV::Packdrakeng to use the externalgzipcommand instead. this has no meaning with other compress programs, because internal functions are not implemented yet. (not yet!! future plans!!)comp_levelβ the compression level passed as an argument to the compression program. by default, this is set to6.block_sizeβ the limit size after which we start a new compressed block. default value is400KB. set it to0to be sure a new block will be started for each packed file, and-1to never start a new block. > be aware that a big block size will slow down the file extraction. like, it's giving slow. plan accordingly bestie.quietβ do not output anything. shut up. π€«debugβ print debug messages.
π open(%options)
opens an existing archive for extracting or adding files.
the uncompression command is found into the archive, and the compression command is deduced from it. detective work. iconic.
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. and 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. π
π MDV::Packdrakeng->add_virtual($type, $filename, $data)
adds a file into archive according passed information. $type gives the type of the file:
'd'β the file will be a directory, store as'$filename'.$datais 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,$filenamewill be its name,$datais 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.
π MDV::Packdrakeng->add($prefix, @files)
adds @files into archive located into $prefix. only directory, files and symlink will be added. for each file, the path should be relative to $prefix and is stored as is.
π MDV::Packdrakeng->extract_virtual(*HANDLE, $filename)
extracts $filename data from archive into the *HANDLE. $filename should be a normal file. (so like, not a directory, not a symlink, a real one. respect the rules babe.)
π MDV::Packdrakeng->extract($destdir, @files)
extracts @files from the archive into $destdir prefix.
π MDV::Packdrakeng->getcontent()
returns three arrayrefs describing files files into archive β respectively directory list, files list and symlink list. three little lists, one for each girlie. π
π MDV::Packdrakeng->infofile($file)
returns type and information about a given file into the archive; that is:
'f'and the the size of the file for a plain file'l'and the linked file for a symlink'd'andundeffor a directoryundefif the file can't be found into archive. π
π MDV::Packdrakeng->infofile($handle)
print to $handle (STDOUT if not specified) the content of the archive.
π MDV::Packdrakeng->dumptoc($handle)
print to $handle (STDOUT if not specified) the table of content of the archive.
β CHANGELOG β
1.10
- use an oo code
add_virtual()now accept a string as file content
glow up. β¨
π AUTHOR π
Olivier Thauvin <nanardon@mandriva.org>, Rafael Garcia-Suarez <rgarciasuarez@mandriva.com>
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. full compatibility, no cap, she speaks the old language fluently π¦
πΈ LICENSE πΈ
This program is free software; you can redistribute it and/or modify it under the terms of GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
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.
okay that's the whole page bestie, you're officially educated π this was perl v5.42.0, dated 2025-07-25, and yes she's still out here being MDV::Packdrakeng(3). go build an archive, slay, bye πβ¨
π¦ where this page comes from
- fedora 43: perl-MDV-Packdrakeng 1.13-40.fc43 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms