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 'binary #:exists 'append)]) (say "after open, file exists?: " (file-exists? the-path)) (say "file size, position: " (file-size the-path) ", " (file-position the-port)) (file-position the-port 1000); should extend the file and fill the intervening space with 0 (say "file size, position: " (file-size the-path) ", " (file-position the-port)) (flush-output the-port) ; ensure that the filling 0s have been written, just to be sure (say "file size, position: " (file-size the-path) ", " (file-position the-port))) The output is: before open, file exists?: #f after open, file exists?: #t file size, position: 0, 0 file size, position: 0, 1000 file size, position: 0, 1000 The file on disk is in fact 0B long. The docs for file-position ( https://docs.racket-lang.org/reference/port-buffers.html#%28def._%28%28quote._~23~25kernel%29._file-position%29%29) include the following: "When file-position <https://docs.racket-lang.org/reference/port-buffers.html#%28def._%28%28quote._~23~25kernel%29._file-position%29%29> sets the position pos beyond the current size of an output file or (byte) string, the file/string is enlarged to size pos and the new region is filled with 0 bytes. If pos is beyond the end of an input file or (byte) string, then reading thereafter returns eof <https://docs.racket-lang.org/reference/port-ops.html#%28def._%28%28quote._~23~25kernel%29._eof%29%29> without changing the port’s position." Given the above, I was expecting the file to end up being 1000 bytes. I'm using Racket 7.1 on OSX 10.11; is this an OS issue or am I misunderstanding something about Racket? -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAE8gKofKWtAKU4ZQk6ai-ydZx7WmY8%3D1GwDUFbW15BpxUSQ1qw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.