About File.rawWrite
torhu
no at spam.invalid
Tue Nov 29 13:20:12 PST 2011
On 29.11.2011 16:00, Denis Shelomovskij wrote:
>
> Your OS is Windows, right? On Windows, rawWrite and rawRead always
> flushes stream, sets binary mode, reads/writes, flushes stream again,
> sets previous mode. This is definitely unnecessary slow - at least it
> should change mode only if needed (the file is opened in a text mode).
> The better solution is to change all other functions so the file mode
> will be changed lazily (for a text file, raw* functions will change file
> mode and leave file in this mode until a call of a function, that really
> needs a file to be in a text mode).
>
> By the way, why this changing mode behaviour is Windows only? Yes, it is
> clearly documented that this is the case, but it isn't documented _why_
> this is the case.
Text mode means that \n in strings is translated to \r\n when writing,
and the other way when reading. That way you can use only LF (\n) to get
linefeeds on all platforms, even if Windows uses CRLF.
More information about the Digitalmars-d-learn
mailing list