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)))