manpagez: man pages & more
info bigloo
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.2.4 Tar

bigloo procedure: tar-read-header [input-port]

Reads a tar header from input-port. If the input-port does not conform the tar format, an IO exception is raised. On success a tar-header descriptor is returned.

bigloo procedure: tar-read-block tar-header [input-port]

Reads the content of the tar-header block.

bigloo procedure: tar-round-up-to-record-size int

Rounds up tar-block sizes.

bigloo procedure: tar-header-name tar-header
bigloo procedure: tar-header-mode tar-header
bigloo procedure: tar-header-uid tar-header
bigloo procedure: tar-header-gid tar-header
bigloo procedure: tar-header-size tar-header
bigloo procedure: tar-header-mtim tar-header
bigloo procedure: tar-header-checksum tar-header
bigloo procedure: tar-header-type tar-header
bigloo procedure: tar-header-linkname tar-header
bigloo procedure: tar-header-uname tar-header
bigloo procedure: tar-header-gname tar-header
bigloo procedure: tar-header-devmajor tar-header
bigloo procedure: tar-header-devminir tar-header

Return various information about tar-header.

The following example simulates the Unix command tar xvfz:

(define (untar path)
   (let ((pz (open-input-gzip-port path)))
      (unwind-protect
	 (let loop ((lst '()))
	    (let ((h (tar-read-header pz)))
	       (if (not h)
		   lst
		   (case (tar-header-type h)
		      ((dir)
		       (let ((path (tar-header-name h)))
			  (if (make-directory path)
			      (loop lst)
			      (error 'untar
				     "Cannot create directory"
				     path))))
		      ((normal)
		       (let* ((path (tar-header-name h))
			      (dir (dirname path)))
			  (when (and (file-exists? dir) (not (directory? dir)))
			     (delete-file dir))
			  (unless (file-exists? dir)
			     (make-directory dir))
			  (with-output-to-file path
			     (lambda ()
				(display (tar-read-block h pz))))
			  (loop (cons path lst))))
		      (else
		       (error 'untar
			      (format "Illegal file type `~a'"
				      (tar-header-type h))
			      (tar-header-name h)))))))
	 (close-input-port pz))))
bigloo procedure: untar input-port [:directory (pwd)] [:file #f]

Untars the archive whose content is provided by the input port input-port.

  • If :file is provided, untar extract the content of the file named :file and returns a string. The file name must exactly matches the files of the archive files names. If the file does not exist, untar returns #f.
  • If :file is not provided, it untars the whole content, in the directory denoted by :directory, which defaults to (pwd). The function untar, returns the whole list of created directories and files.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on March 31, 2014 using texi2html 5.0.

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.