Skip to content
Prev 207379 / 398506 Next

End of File for binary files

On Sun, Jan 24, 2010 at 3:56 AM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
Is this safe?  Is EOF the only case where readBin() returns fewer
elements than you requested?  Does it depend on the type of connection
you are reading from?  Does it depend on OS?

The help("readBin") does not say much about this, but it says:

"If readBin(what = character()) is used incorrectly on a file which
does not contain C-style character strings, warnings (usually many)
are given. From a file or connection, the input will be broken into
pieces of length 10000 with any final part being discarded."

which seems to suggest that you (at least in special cases) can get
fewer items than requested without hitting EOF.  EOF behavior might be
document elsewhere in R.

/Henrik