Description

Reading and writing tar files.

Author

felix

Version

Usage

(require-extension tar)

Download

tar.egg

Documentation

This extension allows extracting files from tar archives and writing files into them.

Reading

procedure: (tar:open-archived-file [PORT])

Reads the next header-record from PORT (which defaults to the value of (current-input-port)) and returns two values: an input-port representing the contents of the next file in the archive and a tar-header record. If no more files are stored in the archive, then #!eof and #f is returned.

Writing

procedure: (tar:write-to-archive FILENAME STRING [PORT #!key mode uid gid modification-time type-flag link-name uname gname devmajor devminor])

Writes the data given in STRING as FILENAME to the archive designated by the output port PORT (which defaults to the value of (current-output-port)).

The keyword arguments specify additional information in the header-record for this file, see the table below for the default used when no arguments are given:

mode (bitwise-ior perm/irusr perm/iwusr perm/irgrp perm/gwgrp perm/iwoth perm/iwoth) Permissions
uid (current-user-id) Numeric user-id of the file owner
gid (current-group-id) Numeric group-id of the file owners
modification-time (current-seconds) Modification-time of the file when it was archived as the number of seconds from Jan.1, 1970 UTC
type-flag 'normal One of symbols normal, oldnormal, link, symlink, chr, blk, dir, fifo, contig
link-name "" Name of a hard or symbolic link
uname (car (user-information uid)) Username of the file owner
gname (car (group-information gid)) Groupname of the file owners
devmajor 0 Major device number of device-files of type blk or chr
devminor 0 Minor device number of device-files of type blk or chr

After the last file, a termination record should be written to the port that represents the archive (invoke tar:write-to-archive with #f as the FILENAME argument).

Accessing header records

procedure: (tar:header? X)

Returns #t when X is a header-record or #f otherwise.

procedure: (tar:header-name HEADER)
procedure: (tar:header-mode HEADER)
procedure: (tar:header-size HEADER)
procedure: (tar:header-uid HEADER)
procedure: (tar:header-gid HEADER)
procedure: (tar:header-modification-time HEADER)
procedure: (tar:header-checksum HEADER)
procedure: (tar:header-type-flag HEADER)
procedure: (tar:header-link-name HEADER)
procedure: (tar:header-magic HEADER)
procedure: (tar:header-uname HEADER)
procedure: (tar:header-gname HEADER)
procedure: (tar:header-devmajor HEADER)
procedure: (tar:header-devminor HEADER)

Accessors for various fields of a tar header record.

License

Copyright (c) 2006-2007, Felix Winkelmann.  All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the Software),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.