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,5 +1,5 @@ ;; 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 @@ -16,7 +16,8 @@ (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") @@ -26,17 +27,16 @@ (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)) |