diff options
Diffstat (limited to 'src/guile/skribilo/utils/files.scm')
-rw-r--r-- | src/guile/skribilo/utils/files.scm | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/guile/skribilo/utils/files.scm b/src/guile/skribilo/utils/files.scm new file mode 100644 index 0000000..6d89d4d --- /dev/null +++ b/src/guile/skribilo/utils/files.scm @@ -0,0 +1,55 @@ +;;; files.scm -- File-related utilities. +;;; +;;; Copyright 2006 Ludovic Courtès <ludovic.courtes@laas.fr> +;;; +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 2 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program; if not, write to the Free Software +;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +;;; USA. + +(define-module (skribilo utils files) + :export (file-prefix file-suffix file-size)) + +;;; Author: Ludovic Courtès +;;; +;;; Commentary: +;;; +;;; This module defines filesystem-related utility functions. +;;; +;;; Code: + +(define (file-size file) + (let ((file-info (false-if-exception (stat file)))) + (if file-info + (stat:size file-info) + #f))) + +(define (file-prefix fn) + (if fn + (let ((dot (string-rindex fn #\.))) + (if dot (substring fn 0 dot) fn)) + "./SKRIBILO-OUTPUT")) + +(define (file-suffix fn) + (if fn + (let ((dot (string-rindex fn #\.))) + (if dot + (substring fn (+ dot 1) (string-length fn)) + "")) + #f)) + + +;;; arch-tag: b63d2a9f-a254-4e2d-8d85-df773bbc4a9b + +;;; files.scm ends here |