From e21427c872d0d0c2c6896a30832fd06fa8b28f70 Mon Sep 17 00:00:00 2001 From: Luis Guilherme Coelho Date: Sun, 7 Jul 2024 16:35:10 -0300 Subject: [PATCH] utils: Add list-contents and almost-basename procedures --- radix/utils.scm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/radix/utils.scm b/radix/utils.scm index 03ff89b..f38743c 100644 --- a/radix/utils.scm +++ b/radix/utils.scm @@ -2,9 +2,12 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (ice-9 match) + #:use-module (ice-9 ftw) #:export (associate-left associate-right - flat-map)) + flat-map + list-contents + almost-basename)) (define-syntax-rule (associate-left (key associations) ...) @@ -26,3 +29,13 @@ list, up to the last list." (lambda arglst (apply proc h arglst)) tail-lsts)) head-lst)))) + +(define (list-contents dir) + (and=> (scandir dir) + (lambda (subdirs) + (map (cut string-append dir "/" <>) + (cddr subdirs))))) + +(define (almost-basename file) + (string-append (basename (dirname file)) + "/" (basename file)))