Read
Object Hierarchy:
Description:
[
Compact ]
[
CCode ( cname =
"struct archive" , free_function =
"archive_read_free" ) ]
public class Read :
Archive
Example: A Complete Extractor:
public void extract (string filename) {
// Select which attributes we want to restore.
Archive.ExtractFlags flags;
flags = Archive.ExtractFlags.TIME;
flags |= Archive.ExtractFlags.PERM;
flags |= Archive.ExtractFlags.ACL;
flags |= Archive.ExtractFlags.FFLAGS;
Archive.Read archive = new Archive.Read ();
archive.support_format_all ();
archive.support_compression_all ();
Archive.WriteDisk extractor = new Archive.WriteDisk ();
extractor.set_options (flags);
extractor.set_standard_lookup ();
if (archive.open_filename (filename, 10240) != Archive.Result.OK) {
critical ("Error opening %s: %s (%d)", filename, archive.error_string (), archive.errno ());
return;
}
unowned Archive.Entry entry;
Archive.Result last_result;
while ((last_result = archive.next_header (out entry)) == Archive.Result.OK) {
if (extractor.write_header (entry) != Archive.Result.OK) {
continue;
}
void* buffer = null;
size_t buffer_length;
Posix.off_t offset;
while (archive.read_data_block (out buffer, out buffer_length, out offset) == Archive.Result.OK) {
if (extractor.write_data_block (buffer, buffer_length, offset) != Archive.Result.OK) {
break;
}
}
}
if (last_result != Archive.Result.EOF) {
critical ("Error: %s (%d)", archive.error_string (), archive.errno ());
}
}
public static int main (string[] args) {
for (int i = 1; i < args.length; i++) {
extract (args[i]);
}
return 0;
}
valac --pkg libarchive Archive.WriteDisk.1.vala
Content:
Creation methods:
Methods:
- public Result append_filter (Filter filter_code)
- public Result append_filter_program (string cmd)
- public Result close ()
- public Result extract (Entry entry, ExtractFlags flags = 0)
- public Result extract2 (Entry entry, Write dest)
- public void extract_set_progress_callback (ExtractProgressCallback cb)
- public void extract_set_skip_file (int64_t dev, int64_t ino)
- public int64_t header_position ()
- public Result next_header (out unowned Entry entry)
- public Result open (OpenCallback ocb, ReadCallback rcb, CloseCallback ccb)
- public Result open2 (OpenCallback ocb, ReadCallback rcb, SkipCallback scb, CloseCallback ccb)
- public Result open_FILE (FileStream file)
- public Result open_fd (int fd, size_t block_size)
- public Result open_filename (string filename, size_t block_size)
- public Result open_memory (uint8[] buffer)
- public ssize_t read_data (uint8[] buffer)
- public Result read_data_block (out unowned uint8[] buffer, out int64_t offset)
- public Result read_data_into_fd (int fd)
- public Result read_data_skip ()
- public Result set_format (Format format_code)
- public Result support_filter_all ()
- public Result support_filter_bzip2 ()
- public Result support_filter_compress ()
- public Result support_filter_grzip ()
- public Result support_filter_gzip ()
- public Result support_filter_lrzip ()
- public Result support_filter_lzip ()
- public Result support_filter_lzma ()
- public Result support_filter_lzop ()
- public Result support_filter_none ()
- public Result support_filter_program (string command)
- public Result support_filter_rpm ()
- public Result support_filter_uu ()
- public Result support_filter_xz ()
- public Result support_format_7zip ()
- public Result support_format_all ()
- public Result support_format_ar ()
- public Result support_format_by_code (Format format_code)
- public Result support_format_cab ()
- public Result support_format_cpio ()
- public Result support_format_empty ()
- public Result support_format_gnutar ()
- public Result support_format_iso9660 ()
- public Result support_format_lha ()
- public Result support_format_mtree ()
- public Result support_format_rar ()
- public Result support_format_raw ()
- public Result support_format_tar ()
- public Result support_format_xar ()
- public Result support_format_zip ()
- public Result support_format_zip_seekable ()
- public Result support_format_zip_streamable ()
Inherited Members:
All known members inherited from class Archive.Archive