Japanese

Gauche-tar

Gauche-tar is a Gauche module which provides reading or writing Tar files written by Gauche only.

Download: Gauche-tar-1.1.2.tgz (2019-5-4)

History

Example

(use tar)
(use gauche.collection)

;;; 
;;; Tar iteration using generator.
;;; 
(let* ((tar (open-input-tar "../testdata/ztestdataposix.tar"))
       (tar-next (tar->generator tar)))
  (describe tar)
  (unwind-protect
   (begin
     (format #t "~S" (tar-next))
     (format #t "~S" (tar-next)))
   (close-input-tar tar)))

(let* ((tar (open-input-tar "../testdata/ztestdataposix.tar"))
       (tar-next (tar->generator tar)))
  (unwind-protect
   (generator-for-each (^x (format #t "~a\n" (~ x 'name))) tar-next)
   (format #t "is closed? ~S\n" (~ tar 'is-closed?))
   (format #t "is generate? ~S\n" (~ tar 'in-generation?))
   (close-input-tar tar)))

;;; 
;;; Extract data from tar to buffer.
;;; 
(let* ((tar (open-input-tar "../testdata/ztestdataposix.tar"))
       (tar-next (tar->generator tar))
       (out (open-output-string)))
  (unwind-protect
   (generator-for-each
    (^x
     (if (#/archive\.c/ (~ x 'name))
       (extract x out)))
    tar-next)
   (format #t "output to buffer [~a]\n" (get-output-string out))
  (close-input-tar tar)))

;;; 
;;; Read tar-gzip.
;;; 
(let ((tar-gz (open-input-tar-gz "posix-build.tar.gz")))
  (guard
      (exc
       ((tar-error? exc)
        (format #t "~a ~a\n"
                (tar-error-message exc)
                (tar-error-debug-info exc))))
    (map (^x (format #t "~S" x)) tar-gz)))