diff options
author | David Thompson <dthompson2@worcester.edu> | 2023-03-25 07:57:55 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2023-03-25 11:06:34 -0400 |
commit | 1225b4c5c922ebcd3848dddf9bb8791509e5dc58 (patch) | |
tree | 8d21532fa1799e6dcdf289da16f2967b0c681b36 | |
parent | c7aba74eb70f109ca38bbc541f285ddb48424237 (diff) |
Add file-extension, absolute-file-name, and tmpdir utility procedures.
-rw-r--r-- | chickadee/utils.scm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/chickadee/utils.scm b/chickadee/utils.scm index 8869e8d..2d218c4 100644 --- a/chickadee/utils.scm +++ b/chickadee/utils.scm @@ -17,9 +17,25 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (chickadee utils) - #:export (memoize + #:use-module (ice-9 match) + #:export (file-extension + absolute-file-name + tmpdir + memoize for-range)) +(define (file-extension file-name) + (match (string-split file-name #\.) + ((_ ... ext) ext))) + +(define (absolute-file-name file-name) + (if (absolute-file-name? file-name) + file-name + (string-append (getcwd) "/" file-name))) + +(define (tmpdir) + (or (getenv "TMPDIR") "/tmp")) + ;; Written by Ludovic Courtès. Taken from GNU Guix. (define (memoize proc) "Return a memoizing version of PROC." |