Consider the following test script:
#lang racket
(define (say . args) (displayln (apply ~a args)))
(define the-path "./test-file")
(when (file-exists? the-path) (delete-file the-path))
(say "before open, file exists?: " (file-exists? the-path))
(let ([the-port (open-output-file the-path #:mode
I *think* that the docs are wrong here. `file-position` maps onto
`lseek` on posix systems (pretty sure about this after a quick perusal
of the code) and `lseek` docs say:
> The lseek() function shall allow the file offset to be set beyond the end of
> the existing data in the file. If data is la
On Mon, Jun 24, 2019 at 4:51 PM Jon Zeppieri wrote:
>
> `lseek` docs say:
>
> > The lseek() function shall allow the file offset to be set beyond the end
> > of the existing data in the file. If data is later written at this point,
> > subsequent reads of data in the gap shall return bytes with
I actually did try writing something at the extended position, although I
removed it before posting the above. Even with a write, it still does not
do as expected. In fact, the results are even stranger:
#lang racket
(define (say . args) (displayln (apply ~a args)))
(define the-path "./test-fil
I think that part is because you've opened the file in 'append mode.
At the OS level, 'append means "move to the end of the file before each
write". So, 'append and `file-position` to extend a file size just
don't work helpfully together.
I'll improve the docs.
At Mon, 24 Jun 2019 17:09:05 -0400
On Mon, Jun 24, 2019 at 4:09 PM David Storrs wrote:
>
> I actually did try writing something at the extended position, although I
> removed it before posting the above. Even with a write, it still does not do
> as expected. In fact, the results are even stranger:
>
> #lang racket
>
> (define (
On Mon, Jun 24, 2019 at 5:19 PM Shu-Hung You <
shu-hung@eecs.northwestern.edu> wrote:
>
>
> FWIW, (write "foo") writes "\"foo\"" to the file. Maybe you want
> write-string or write-bytes?
>
*facepalm*
I think I want a better brain. Thank you.
Matthew, thanks for the clarification about ap
7 matches
Mail list logo