unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27290: [PATCH] file-systems: Provide string->iso9660-uuid.
@ 2017-06-08 19:26 Danny Milosavljevic
  2017-06-08 21:20 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Danny Milosavljevic @ 2017-06-08 19:26 UTC (permalink / raw)
  To: 27290

* gnu/build/file-systems.scm (string->iso9660-uuid): New variable.  Export it.
---
 gnu/build/file-systems.scm | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 7737de3d0..1c733f43b 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -43,6 +43,7 @@
 
             uuid->string
             string->uuid
+            string->iso9660-uuid
 
             bind-mount
 
@@ -235,6 +236,27 @@ Trailing spaces are trimmed."
 
 ;; <http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf>.
 
+(define %iso9660-uuid-rx
+  ;;                   Y                m                d                H                M                S                ss
+  (make-regexp "^([[:digit:]]{4})-([[:digit:]]{2})-([[:digit:]]{2})-([[:digit:]]{2})-([[:digit:]]{2})-([[:digit:]]{2})-([[:digit:]]{2})$"))
+
+(define (string->iso9660-uuid str)
+  "Parse STR as a ISO9660 UUID (which is really a timestamp - see /dev/disk/by-uuid).
+Return its contents as a 16-byte bytevector.  Return #f if STR is not a valid
+ISO9660 UUID representation."
+  (and=> (regexp-exec %iso9660-uuid-rx str)
+         (lambda (match)
+           (letrec-syntax ((match-numerals
+                            (syntax-rules ()
+                              ((_ index (name rest ...) body)
+                               (let ((name (match:substring match index)))
+                                 (match-numerals (+ 1 index) (rest ...) body)))
+                              ((_ index () body)
+                               body))))
+            (match-numerals 1 (year month day hour minute second hundredths)
+              (string->utf8 (string-append year month day
+                                           hour minute second hundredths)))))))
+
 (define (iso9660-superblock? sblock)
   "Return #t when SBLOCK is an iso9660 volume descriptor."
   (bytevector=? (sub-bytevector sblock 1 6)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#27290: [PATCH] file-systems: Provide string->iso9660-uuid.
  2017-06-08 19:26 bug#27290: [PATCH] file-systems: Provide string->iso9660-uuid Danny Milosavljevic
@ 2017-06-08 21:20 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2017-06-08 21:20 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 27290

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> * gnu/build/file-systems.scm (string->iso9660-uuid): New variable.  Export it.

LGTM, thanks!

Ludo'.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-08 21:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-08 19:26 bug#27290: [PATCH] file-systems: Provide string->iso9660-uuid Danny Milosavljevic
2017-06-08 21:20 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).