diff options
Diffstat (limited to 'scheme/idest/batch/setpic.scm')
-rw-r--r-- | scheme/idest/batch/setpic.scm | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/scheme/idest/batch/setpic.scm b/scheme/idest/batch/setpic.scm index c0670a3..834a571 100644 --- a/scheme/idest/batch/setpic.scm +++ b/scheme/idest/batch/setpic.scm @@ -1,8 +1,8 @@ ;; This file is part of Idest -;; Copyright (C) 2011 Sergey Poznyakoff +;; Copyright (C) 2011, 2015 Sergey Poznyakoff ;; ;; Idest 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 3, or (at your option) ;; any later version. ;; @@ -13,33 +13,33 @@ ;; ;; You should have received a copy of the GNU General Public License ;; along with Idest. If not, see <http://www.gnu.org/licenses/>. (define-module (idest batch setpic)) -(use-modules (ice-9 getopt-long)) +(use-modules (ice-9 getopt-long) + (rnrs io ports)) (define-public description "set attached picture from a file") (define-public idest-main #f) (define (read-picture file) (with-output-to-string (lambda () - (with-input-from-file - file - (lambda () - (let loop ((chr (read-char))) + (let ((port (open-file-input-port file))) + (let ((get-byte (lambda () (get-u8 port)))) + (let loop ((n (get-byte))) (cond - ((not (eof-object? chr)) - (let ((n (char->integer chr))) - (if (< n 16) - (display "0")) - (display (number->string n 16))) - (loop (read-char)))))))))) + ((not (eof-object? n)) + (if (< n 16) + (display "0")) + (display (number->string n 16)) + (loop (get-byte)))))) + (close-port port))))) (define-public (idest-init) (let* ((cmd (command-line)) (progname (car cmd)) (description "") (mime-type #f) |