ZlibCompressor
Object Hierarchy:
GLib.ZlibCompressor
GLib.ZlibCompressor
GLib.ZlibCompressor
GLib.Object
GLib.Object
GLib.Object->GLib.ZlibCompressor
GLib.Converter
GLib.Converter
GLib.Converter->GLib.ZlibCompressor
Description:
[
CCode ( type_id =
"g_zlib_compressor_get_type ()" ) ]
public class ZlibCompressor :
Object ,
Converter
ZlibCompressor is an implementation of Converter that
compresses data using zlib.
Example: ZLib-Compression:
private const ZlibCompressorFormat FORMAT = ZlibCompressorFormat.GZIP;private void convert (File source, File dest, Converter converter) throws Error { var src_stream = source.read (); var dst_stream = dest.replace (null , false , 0 ); var conv_stream = new ConverterOutputStream (dst_stream, converter); // 'splice' pumps all data from an InputStream to an OutputStream conv_stream.splice (src_stream, 0 ); }public int main (string [] args) { if (args.length < 2 ) { print ("Usage: %s FILE \n " , args[0 ]); return 0 ; } var infile = File.new_for_commandline_arg (args[1 ]); if (!infile.query_exists ()) { stderr.printf ("File ' %s ' does not exist. \n " , args[1 ]); return 1 ; } var zipfile = File.new_for_commandline_arg (args[1 ] + ".gz" ); var outfile = File.new_for_commandline_arg (args[1 ] + "_out" ); try { convert (infile, zipfile, new ZlibCompressor (FORMAT)); convert (zipfile, outfile, new ZlibDecompressor (FORMAT)); } catch (Error e) { stderr.printf (" %s \n " , e.message); return 1 ; } return 0 ; }
valac --pkg gio-2.0 GLib.ZlibCompressor.vala
Example: ZLib-Compression:
private const ZlibCompressorFormat FORMAT = ZlibCompressorFormat.GZIP;private void convert (File source, File dest, Converter converter) throws Error { var src_stream = source.read (); var dst_stream = dest.replace (null , false , 0 ); var conv_stream = new ConverterOutputStream (dst_stream, converter); // 'splice' pumps all data from an InputStream to an OutputStream conv_stream.splice (src_stream, 0 ); }public int main (string [] args) { if (args.length < 2 ) { print ("Usage: %s FILE \n " , args[0 ]); return 0 ; } var infile = File.new_for_commandline_arg (args[1 ]); if (!infile.query_exists ()) { stderr.printf ("File ' %s ' does not exist. \n " , args[1 ]); return 1 ; } var zipfile = File.new_for_commandline_arg (args[1 ] + ".gz" ); var outfile = File.new_for_commandline_arg (args[1 ] + "_out" ); try { convert (infile, zipfile, new ZlibCompressor (FORMAT)); convert (zipfile, outfile, new ZlibDecompressor (FORMAT)); } catch (Error e) { stderr.printf (" %s \n " , e.message); return 1 ; } return 0 ; }
valac --pkg gio-2.0 GLib.ZlibCompressor.vala
Content:
Properties:
public FileInfo file_info { get ; set ; }
If set to a non-null
FileInfo object, and format
is g_zlib_compressor_format_gzip , the compressor will write the file name and modification time
from the file info to the GZIP header.
public ZlibCompressorFormat format { get ; construct ; }
public int level { get ; construct ; }
Creation methods:
Methods:
Inherited Members:
All known members inherited from class GLib.Object
@get
@new
@ref
@set
add_toggle_ref
add_weak_pointer
bind_property
connect
constructed
disconnect
dispose
dup_data
dup_qdata
force_floating
freeze_notify
get_class
get_data
get_property
get_qdata
get_type
getv
interface_find_property
interface_install_property
interface_list_properties
is_floating
new_valist
new_with_properties
newv
notify
notify_property
ref_count
ref_sink
remove_toggle_ref
remove_weak_pointer
replace_data
replace_qdata
set_data
set_data_full
set_property
set_qdata
set_qdata_full
set_valist
setv
steal_data
steal_qdata
thaw_notify
unref
watch_closure
weak_ref
weak_unref
All known members inherited from interface GLib.Converter