summary refs log tree commit diff
path: root/src/guile
diff options
context:
space:
mode:
authorLudovic Court`es2006-02-14 14:34:50 +0000
committerLudovic Court`es2006-02-14 14:34:50 +0000
commitc7f820101026526e4d0d72ba4999a1b0fa9ebbb8 (patch)
tree705f8f94af1bc5b5b7d276b3b0dc5945927bc3b5 /src/guile
parent8f5bd5e1126f1866921eb247ef55ed5b32c966f9 (diff)
downloadskribilo-c7f820101026526e4d0d72ba4999a1b0fa9ebbb8.tar.gz
skribilo-c7f820101026526e4d0d72ba4999a1b0fa9ebbb8.tar.lz
skribilo-c7f820101026526e4d0d72ba4999a1b0fa9ebbb8.zip
Created the `(skribilo utils files)' module.
* src/guile/skribilo/package/slide.scm: Fixed calls to `format'.

* src/guile/skribilo/runtime.scm: Use `(skribilo utils files)'.  Use
  `file-suffix' and `file-prefix' instead of `suffix' and `prefix'.
  Removed local definition of `suffix'.

* src/guile/skribilo/utils/compat.scm: Use `(skribilo utils files)'.
  Moved `file-suffix' and `file-prefix' there.

* src/guile/skribilo/utils/files.scm: New.

* src/guile/skribilo/utils/Makefile.am (dist_guilemodule_DATA): Added
  `files.scm'.

git-archimport-id: lcourtes@laas.fr--2004-libre/skribilo--devel--1.2--patch-44
Diffstat (limited to 'src/guile')
-rw-r--r--src/guile/skribilo/package/slide.scm4
-rw-r--r--src/guile/skribilo/runtime.scm17
-rw-r--r--src/guile/skribilo/utils/Makefile.am2
-rw-r--r--src/guile/skribilo/utils/compat.scm15
-rw-r--r--src/guile/skribilo/utils/files.scm55
5 files changed, 66 insertions, 27 deletions
diff --git a/src/guile/skribilo/package/slide.scm b/src/guile/skribilo/package/slide.scm
index ddbbd1d..5b39239 100644
--- a/src/guile/skribilo/package/slide.scm
+++ b/src/guile/skribilo/package/slide.scm
@@ -366,7 +366,7 @@
 			      (tr (th :align 'left
 				     (list
 				      (if nb
-					  (format "~a / ~a -- " nb
+					  (format #f "~a / ~a -- " nb
 						  (slide-number)))
 				      t)))
 			      (tr (td (hrule)))
@@ -662,7 +662,7 @@
       (let* ((cap (engine-custom le 'slide-caption))
 	     (o (engine-custom le 'predocument))
 	     (n (if (string? cap)
-		    (format "~a\\slideCaption{~a}\n"
+		    (format #f "~a\\slideCaption{~a}\n"
 			    &slide-prosper-predocument
 			    cap)
 		    &slide-prosper-predocument)))
diff --git a/src/guile/skribilo/runtime.scm b/src/guile/skribilo/runtime.scm
index e302ee9..bd8497f 100644
--- a/src/guile/skribilo/runtime.scm
+++ b/src/guile/skribilo/runtime.scm
@@ -1,8 +1,7 @@
-;;;
 ;;; runtime.scm	-- Skribilo runtime system
 ;;;
-;;; Copyright © 2003-2004 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
-;;; Copyright © 2005 Ludovic Courtès <ludovic.courtes@laas.fr>
+;;; Copyright 2003, 2004  Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
+;;; Copyright 2005, 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
@@ -35,15 +34,11 @@
   :use-module (skribilo lib)
   :use-module (srfi srfi-13)
   :use-module (srfi srfi-35)
+  :autoload   (skribilo utils files) (file-prefix file-suffix)
   :autoload   (skribilo condition) (&file-search-error)
   :autoload   (srfi srfi-34) (raise))
 
 
-(define (suffix path)
-  (let ((dot (string-rindex path #\.)))
-    (if (not dot)
-	path
-	(substring path (+ dot 1) (string-length path)))))
 
 ;;; ======================================================================
 ;;;
@@ -108,8 +103,8 @@
 ;;;
 ;;; ======================================================================
 (define (builtin-convert-image from fmt dir)
-  (let* ((s  (suffix from))
-	 (f  (string-append (prefix (basename from)) "." fmt))
+  (let* ((s  (file-suffix from))
+	 (f  (string-append (file-prefix (basename from)) "." fmt))
 	 (to (string-append dir "/" f)))   ;; FIXME:
     (cond
       ((string=? s fmt)
@@ -133,7 +128,7 @@
     (if (not path)
 	(raise (condition (&file-search-error (file-name file)
 					      (path (*image-path*)))))
-	(let ((suf (suffix file)))
+	(let ((suf (file-suffix file)))
 	  (if (member suf formats)
 	      (let* ((dir (if (string? (*destination-file*))
 			      (dirname (*destination-file*))
diff --git a/src/guile/skribilo/utils/Makefile.am b/src/guile/skribilo/utils/Makefile.am
index 6a82ac7..5044c1b 100644
--- a/src/guile/skribilo/utils/Makefile.am
+++ b/src/guile/skribilo/utils/Makefile.am
@@ -1,4 +1,4 @@
 guilemoduledir = $(GUILE_SITE)/skribilo/utils
-dist_guilemodule_DATA = syntax.scm compat.scm
+dist_guilemodule_DATA = syntax.scm compat.scm files.scm
 
 ## arch-tag: 3a18b64b-1da2-417b-8338-2c534bca277f
diff --git a/src/guile/skribilo/utils/compat.scm b/src/guile/skribilo/utils/compat.scm
index a7ce781..3fce068 100644
--- a/src/guile/skribilo/utils/compat.scm
+++ b/src/guile/skribilo/utils/compat.scm
@@ -21,6 +21,7 @@
 
 (define-module (skribilo utils compat)
   :use-module (skribilo utils syntax)
+  :use-module (skribilo utils files)
   :use-module (skribilo parameters)
   :use-module (skribilo evaluator)
   :use-module (srfi srfi-1)
@@ -30,6 +31,7 @@
   :use-module (ice-9 optargs)
   :autoload   (skribilo ast) (ast?)
   :autoload   (skribilo condition) (file-search-error? &file-search-error)
+  :re-export (file-size)
   :replace (gensym))
 
 ;;; Author:  Ludovic Courtès
@@ -197,19 +199,6 @@
 	  (for-each display args)
 	  (display "\n")))))
 
-(define-public (file-prefix fn)
-  (if fn
-      (let ((dot (string-rindex fn #\.)))
-	(if dot (substring fn 0 dot) fn))
-      "./SKRIBILO-OUTPUT"))
-
-(define-public (file-suffix fn)
-  (if fn
-      (let ((dot (string-rindex fn #\.)))
-	(if dot
-	    (substring fn (+ dot 1) (string-length fn))
-	    ""))
-      #f))
 
 
 (define-public prefix			file-prefix)
diff --git a/src/guile/skribilo/utils/files.scm b/src/guile/skribilo/utils/files.scm
new file mode 100644
index 0000000..7eb1cf2
--- /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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+;;; 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