Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dpkg::compression::process(3) [linux man page]

Dpkg::Compression::Process(3)					   libdpkg-perl 				     Dpkg::Compression::Process(3)

NAME
Dpkg::Compression::Process - run compression/decompression processes DESCRIPTION
This module provides an object oriented interface to run and manage compression/decompression processes. METHODS
my $proc = Dpkg::Compression::Process->new(%opts) Create a new instance of the object. Supported options are "compression" and "compression_level" (see corresponding set_* functions). $proc->set_compression($comp) Select the compression method to use. It errors out if the method is not supported according to "compression_is_supported" (of Dpkg::Compression). $proc->set_compression_level($level) Select the compression level to use. It errors out if the level is not valid according to "compression_is_valid_level" (of Dpkg::Compression). my @exec = $proc->get_compress_cmdline() my @exec = $proc->get_uncompress_cmdline() Returns a list ready to be passed to "exec", its first element is the program name (either for compression or decompression) and the following elements are parameters for the program. When executed the program acts as a filter between its standard input and its standard output. $proc->compress(%opts) Starts a compressor program. You must indicate where it will read its uncompressed data from and where it will write its compressed data to. This is accomplished by passing one parameter "to_*" and one parameter "from_*" as accepted by Dpkg::IPC::spawn. You must call "wait_end_process" after having called this method to properly close the sub-process (and verify that it exited without error). $proc->uncompress(%opts) Starts a decompressor program. You must indicate where it will read its compressed data from and where it will write its uncompressed data to. This is accomplished by passing one parameter "to_*" and one parameter "from_*" as accepted by Dpkg::IPC::spawn. You must call "wait_end_process" after having called this method to properly close the sub-process (and verify that it exited without error). $proc->wait_end_process(%opts) Call Dpkg::IPC::wait_child to wait until the sub-process has exited and verify its return code. Any given option will be forwarded to the "wait_child" function. Most notably you can use the "nocheck" option to verify the return code yourself instead of letting "wait_child" do it for you. AUTHOR
Raphael Hertzog <hertzog@debian.org>. 1.16.0.3 2012-04-17 Dpkg::Compression::Process(3)

Check Out this Related Man Page

Dpkg::Compression::FileHandle(3)				   libdpkg-perl 				  Dpkg::Compression::FileHandle(3)

NAME
Dpkg::Compression::FileHandle - object dealing transparently with file compression SYNOPSIS
use Dpkg::Compression::FileHandle; $fh = Dpkg::Compression::FileHandle->new(filename=>"sample.gz"); print $fh "Something "; close $fh; $fh = Dpkg::Compression::FileHandle->new(); open($fh, ">", "sample.bz2"); print $fh "Something "; close $fh; $fh = Dpkg::Compression::FileHandle->new(); $fh->open("sample.xz", "w"); $fh->print("Something "); $fh->close(); $fh = Dpkg::Compression::FileHandle->new(filename=>"sample.gz"); my @lines = <$fh>; close $fh; $fh = Dpkg::Compression::FileHandle->new(); open($fh, "<", "sample.bz2"); my @lines = <$fh>; close $fh; $fh = Dpkg::Compression::FileHandle->new(); $fh->open("sample.xz", "r"); my @lines = $fh->getlines(); $fh->close(); DESCRIPTION
Dpkg::Compression::FileHandle is an object that can be used like any filehandle and that deals transparently with compressed files. By default, the compression scheme is guessed from the filename but you can override this behaviour with the method "set_compression". If you don't open the file explicitly, it will be auto-opened on the first read or write operation based on the filename set at creation time (or later with the "set_filename" method). Once a file has been opened, the filehandle must be closed before being able to open another file. STANDARD FUNCTIONS
The standard functions acting on filehandles should accept a Dpkg::Compression::FileHandle object transparently including "open" (only when using the variant with 3 parameters), "close", "binmode", "eof", "fileno", "getc", "print", "printf", "read", "sysread", "say", "write", "syswrite", "seek", "sysseek", "tell". Note however that "seek" and "sysseek" will only work on uncompressed files as compressed files are really pipes to the compressor programs and you can't seek on a pipe. FileHandle METHODS The object inherits from FileHandle so all methods that work on this object should work for Dpkg::Compression::FileHandle too. There may be exceptions though. PUBLIC METHODS
my $fh = Dpkg::Compression::FileHandle->new(%opts) Creates a new filehandle supporting on-the-fly compression/decompression. Supported options are "filename", "compression", "compression_level" (see respective set_* functions) and "add_comp_ext". If "add_comp_ext" evaluates to true, then the extension corresponding to the selected compression scheme is automatically added to the recorded filename. It's obviously incompatible with automatic detection of the compression method. $fh->ensure_open($mode) Ensure the file is opened in the requested mode ("r" for read and "w" for write). Opens the file with the recorded filename if needed. If the file is already open but not in the requested mode, then it errors out. $fh->set_compression($comp) Defines the compression method used. $comp should one of the methods supported by Dpkg::Compression or "none" or "auto". "none" indicates that the file is uncompressed and "auto" indicates that the method must be guessed based on the filename extension used. $fh->set_compression_level($level) Indicate the desired compression level. It should be a value accepted by the function "compression_is_valid_level" of Dpkg::Compression. $fh->set_filename($name, [$add_comp_ext]) Use $name as filename when the file must be opened/created. If $add_comp_ext is passed, it indicates whether the default extension of the compression method must be automatically added to the filename (or not). my $file = $fh->get_filename() Returns the filename that would be used when the filehandle must be opened (both in read and write mode). This function errors out if "add_comp_ext" is enableactivated while the compression method is set to "auto". The returned filename includes the extension of the compression method if "add_comp_ext" is enabled. $ret = $fh->use_compression() Returns "0" if no compression is used and the compression method used otherwise. If the compression is set to "auto", the value returned depends on the extension of the filename obtained with the get_filename method. my $real_fh = $fh->get_filehandle() Returns the real underlying filehandle. Useful if you want to pass it along in a derived object. DERIVED OBJECTS
If you want to create an object that inherits from Dpkg::Compression::FileHandle you must be aware that the object is a reference to a GLOB that is returned by Symbol::gensym() and as such it's not a HASH. You can store internal data in a hash but you have to use "*$self-"{...}> to access the associated hash like in the example below: sub set_option { my ($self, $value) = @_; *$self->{"option"} = $value; } AUTHOR
Raphael Hertzog <hertzog@debian.org> 1.16.0.3 2012-04-17 Dpkg::Compression::FileHandle(3)
Man Page