Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

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

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

NAME
Dpkg::Compression - simple database of available compression methods DESCRIPTION
This modules provides a few public funcions and a public regex to interact with the set of supported compression methods. EXPORTED VARIABLES
$compression_re_file_ext A regex that matches a file extension of a file compressed with one of the supported compression methods. EXPORTED FUNCTIONS
my @list = compression_get_list() Returns a list of supported compression methods (sorted alphabetically). compression_is_supported($comp) Returns a boolean indicating whether the give compression method is known and supported. compression_get_property($comp, $property) Returns the requested property of the compression method. Returns undef if either the property or the compression method doesn't exist. Valid properties currently include "file_ext" for the file extension, "comp_prog" for the name of the compression program and "decomp_prog" for the name of the decompression program. compression_guess_from_filename($filename) Returns the compression method that is likely used on the indicated filename based on its file extension. my $comp = compression_get_default() Return the default compression method. It's "gzip" unless "compression_set_default" has been used to change it. compression_set_default($comp) Change the default compression method. Errors out if the given compression method is not supported. my $level = compression_get_default_level() Return the default compression level used when compressing data. It's "9" unless "compression_set_default_level" has been used to change it. compression_set_default_level($level) Change the default compression level. Errors out if the level is not valid (see "compression_is_valid_level"). either a number between 1 and 9 or "fast" or "best". compression_is_valid_level($level) Returns a boolean indicating whether $level is a valid compression level (it must be either a number between 1 and 9 or "fast" or "best") AUTHOR
Raphael Hertzog <hertzog@debian.org>. 1.16.0.3 2012-04-17 Dpkg::Compression(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