From a63d9a7c1e1065350100548e5193fa7f7fbec9bc Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Sat, 28 Dec 2019 01:45:19 +0200 Subject: [PATCH] Add parameters to customize file attributes --- trivial-tar-writer.scm | 13 +++++++++---- trivial-tar-writer.sld | 6 +++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/trivial-tar-writer.scm b/trivial-tar-writer.scm index 8dcd44b..28f0f20 100644 --- a/trivial-tar-writer.scm +++ b/trivial-tar-writer.scm @@ -1,6 +1,11 @@ ;; Copyright 2019 Lassi Kortela ;; SPDX-License-Identifier: ISC +(define tar-unix-time (make-parameter 0)) +(define tar-unix-mode (make-parameter #o644)) +(define tar-owner-name (make-parameter "root")) +(define tar-group-name (make-parameter "root")) + (define nulls (make-bytevector 512 0)) (define blank-checksum (make-bytevector 7 (char->integer #\space))) @@ -34,19 +39,19 @@ (header-before-checksum (bytevector-append (tar-string 100 fake-path) - (tar-octal 8 #o644) + (tar-octal 8 (tar-unix-mode)) (tar-octal 8 0) (tar-octal 8 0) (tar-octal 12 nbyte) - (tar-octal 12 unix-time-now))) + (tar-octal 12 (tar-unix-time)))) (header-after-checksum (bytevector-append (bytevector (char->integer #\space)) (bytevector (char->integer #\0)) (tar-string 100 "") (tar-string 8 "ustar ") - (tar-string 32 "root") - (tar-string 32 "root") + (tar-string 32 (tar-owner-name)) + (tar-string 32 (tar-group-name)) (make-bytevector 183 0))) (checksum (tar-octal 7 (tar-checksum header-before-checksum blank-checksum diff --git a/trivial-tar-writer.sld b/trivial-tar-writer.sld index ece275e..8f3e43d 100644 --- a/trivial-tar-writer.sld +++ b/trivial-tar-writer.sld @@ -1,5 +1,9 @@ (define-library (trivial-tar-writer) - (export tar-write-file + (export tar-unix-time + tar-unix-mode + tar-owner-name + tar-group-name + tar-write-file tar-write-end) (import (scheme base) (scheme char)