Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

text vs. binary file open on Cygwin



Under cygwin (and MS in general) they are different. Binary mode reads/write
files as is; text mode translates between internal LF and external CR-LF for
line ends.

Cygwin is using very elaborate scheme (at least, I like it) to allow both Unix
and Windows environment to coexist. The description is on
<http://www.cygwin.com/cygwin-ug-net/using-textbinary.html>. Side effect of
this implementation is, if you create file on binary-mounted directory, then
move it to text-mounted one and read, you probably won't get expected results.

As a rule of thumb (my own) - if you use binary file, use explicit O_BINARY;
if you use text file - leave it to system (a.k.a. cygwin) to decide.

Currently I see at least two places, where we must use binary:

- wordcode files (creation and reading). Is it possible for these files to
contain explicit NL and CR-NL? Casual tests did not show problems; still,
files are obviously binary.

- memory mapped files. We do not support mmap on Cygwin, but we emulate it.
And mmap is supposed to give you exact content of the file. Side effect is,
that $(<file) is (possibly) no more the same as $mapfiles[file], but I do not
see any workaround.

Is there any other place where Zsh must (internally) use binary mode?

Another question is, should we expose text vs. binary at user level? E.g.
option to force pipes and/or redirections to be in explicit mode? But it is
probably too far fetching.

-andrej

Have a nice DOS!
B >>



Messages sorted by: Reverse Date, Date, Thread, Author