| Line 41... |
Line 41... |
| 41 |
|
41 |
|
| 42 |
\code{where} is stored as a real but should represent an integer:
|
42 |
\code{where} is stored as a real but should represent an integer:
|
| 43 |
non-integer values are likely to be truncated. Note that the possible
|
43 |
non-integer values are likely to be truncated. Note that the possible
|
| 44 |
values can exceed the largest representable number in an \R
|
44 |
values can exceed the largest representable number in an \R
|
| 45 |
\code{integer} on 64-bit builds, and on some 32-bit builds.
|
45 |
\code{integer} on 64-bit builds, and on some 32-bit builds.
|
| 46 |
|
46 |
|
| 47 |
File connections can be open for both writing/appending, in which case
|
47 |
File connections can be open for both writing/appending, in which case
|
| 48 |
\R keeps separate positions for reading and writing. Which \code{seek}
|
48 |
\R keeps separate positions for reading and writing. Which \code{seek}
|
| 49 |
refers to can be set by its \code{rw} argument: the default is the
|
49 |
refers to can be set by its \code{rw} argument: the default is the
|
| 50 |
last mode (reading or writing) which was used. Most files are
|
50 |
last mode (reading or writing) which was used. Most files are
|
| 51 |
only opened for reading or writing and so default to that state. If a
|
51 |
only opened for reading or writing and so default to that state. If a
|
| Line 57... |
Line 57... |
| 57 |
for modes \code{"r+"} and \code{"r+b"}, otherwise at the end of the
|
57 |
for modes \code{"r+"} and \code{"r+b"}, otherwise at the end of the
|
| 58 |
file. Some platforms only allow writing at the end of the file in
|
58 |
file. Some platforms only allow writing at the end of the file in
|
| 59 |
the append modes. (The reported write position for a file opened in
|
59 |
the append modes. (The reported write position for a file opened in
|
| 60 |
an append mode will typically be unreliable until the file has been
|
60 |
an append mode will typically be unreliable until the file has been
|
| 61 |
written to.)
|
61 |
written to.)
|
| 62 |
|
62 |
|
| 63 |
\code{gzfile} connections support \code{seek} with a number of
|
63 |
\code{gzfile} connections support \code{seek} with a number of
|
| 64 |
limitations, using the file position of the uncompressed file.
|
64 |
limitations, using the file position of the uncompressed file.
|
| 65 |
They do not support \code{origin = "end"}. When writing, seeking is
|
65 |
They do not support \code{origin = "end"}. When writing, seeking is
|
| 66 |
only possible forwards: when reading seeking backwards is supported by
|
66 |
only possible forwards: when reading seeking backwards is supported by
|
| 67 |
rewinding the file and re-reading from its start.
|
67 |
rewinding the file and re-reading from its start.
|
| 68 |
|
68 |
|
| 69 |
If \code{seek} is called with a non-\code{NA} value of \code{where},
|
69 |
If \code{seek} is called with a non-\code{NA} value of \code{where},
|
| 70 |
any pushback on a text-mode connection is discarded.
|
70 |
any pushback on a text-mode connection is discarded.
|
| 71 |
|
71 |
|
| 72 |
\code{truncate} truncates a file opened for writing at its current
|
72 |
\code{truncate} truncates a file opened for writing at its current
|
| 73 |
position. It works only for \code{file} connections, and is not
|
73 |
position. It works only for \code{file} connections, and is not
|
| 74 |
implemented on all platforms: on others (including Windows) it will
|
74 |
implemented on all platforms: on others (including Windows) it will
|
| 75 |
not work for large (> 2Gb) files.
|
75 |
not work for large (> 2Gb) files.
|
| 76 |
|
76 |
|
| 77 |
None of these should be expected to work on text-mode connections with
|
77 |
None of these should be expected to work on text-mode connections with
|
| 78 |
re-encoding selected.
|
78 |
re-encoding selected.
|
| 79 |
}
|
79 |
}
|
| 80 |
\section{Warning}{
|
80 |
\section{Warning}{
|
| 81 |
Use of \code{seek} on Windows is discouraged. We have found so many
|
81 |
Use of \code{seek} on Windows is discouraged. We have found so many
|