[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-janitors] #1200: file->byte-blob can only read files in tex
From: |
Chicken Trac |
Subject: |
Re: [Chicken-janitors] #1200: file->byte-blob can only read files in text mode on Windows |
Date: |
Wed, 15 Jul 2015 14:57:39 -0000 |
#1200: file->byte-blob can only read files in text mode on Windows
-------------------------+-----------------------
Reporter: dthedens | Owner:
Type: defect | Status: new
Priority: minor | Milestone: someday
Component: extensions | Version: 4.9.x
Resolution: | Keywords: byte-blob
-------------------------+-----------------------
Comment (by dthedens):
This code creates an 8 byte file with an `eof` character in the middle and
reads it with `file->byte-blob`. On Windows it returns `4` as the length
of the result instead of the expected `8`.
{{{
(use srfi-4 byte-blob)
(begin
(with-output-to-file "testfile.dat"
(lambda () (write-u8vector (list->u8vector (list 1 2 3 4 26 25 24
23)))))
(let ((bblob (file->byte-blob "testfile.dat")))
(byte-blob-length bblob)))
}}}
This workaround code uses the `#:binary` keyword to read in the file
correctly and returns `8`.
{{{
(use srfi-4 byte-blob)
(begin
(with-output-to-file "testfile.dat"
(lambda () (write-u8vector (list->u8vector (list 1 2 3 4 26 25 24
23)))))
(let ((bblob (with-input-from-file "testfile.dat"
(lambda () (byte-blob-read (current-input-port) 8))
#:binary)))
(byte-blob-length bblob)))
}}}
A compatible change to the API would be to allow
{{{
(file->byte-blob "testfile.dat" #:binary)
}}}
using an optional argument (`#:text` is the other option with other
procedures). I could also see making the behavior in `file->byte-blob` be
`#:binary`. This would not affect linux where everything is binary, but in
theory would change behavior on Windows.
--
Ticket URL: <http://bugs.call-cc.org/ticket/1200#comment:2>
CHICKEN Scheme <http://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.
- [Chicken-janitors] #1200: file->byte-blob can only read files in text mode on Windows, Chicken Trac, 2015/07/14
- Re: [Chicken-janitors] #1200: file->byte-blob can only read files in text mode on Windows, Chicken Trac, 2015/07/14
- Re: [Chicken-janitors] #1200: file->byte-blob can only read files in text mode on Windows,
Chicken Trac <=
- Re: [Chicken-janitors] #1200: file->byte-blob can only read files in text mode on Windows, Chicken Trac, 2015/07/15
- Re: [Chicken-janitors] #1200: file->byte-blob can only read files in text mode on Windows, Chicken Trac, 2015/07/15
- Re: [Chicken-janitors] #1200: file->byte-blob can only read files in text mode on Windows, Chicken Trac, 2015/07/16
- Re: [Chicken-janitors] #1200: file->byte-blob can only read files in text mode on Windows, Chicken Trac, 2015/07/16