Add std.stdio.File.setRawMode().#3929
Conversation
094827b to
8e32de3
Compare
Especially for files that cannot be opened by the user in binary mode (like stdin and stdout), rawWrite and rawRead are very limiting. To enable binary/raw file operation for stdin and stdout, the code to set those streams to binary mode is non-trivial. setRawMode() resolves this issue.
8e32de3 to
1180f52
Compare
|
(made fixes, squashed into one commit again) |
|
Looks reasonable. |
|
Hmm. I don't like exposing OS-level implementation details like this. I prefer |
|
I don't disagree with the idea, but this needs to be a toggle. "Binary mode" is also the correct term here. An alternative would be to provide a way to reopen stdin/out/err with arbitrary modes.
For the record this is the C library API and Windows-only, so nothing OS-level. BTW, this needs a correspoding Bugzilla issue. |
Perhaps these can be combined into a property, |
|
About lockingBinaryWriter: yes, would be great! But, it is not exactly the same: it locks. About OS-level stuff: I think the basic problem is not setmode, it is the Digital Mars IO stuff that is troublesome. There should be a function (with sane name) for I first thought about setBinaryMode, setTextMode, but then I thought that that would somehow expose to much detail (and it doesn't actually set binary mode on non-Windows). Then I figured that the functionality is basically a permanent rawWrite, so "raw" stuck. |
There was a problem hiding this comment.
variable not used, remove.
|
Note that if you include |
| See_Also: | ||
| $(LREF rawRead) | ||
| $(LREF rawWrite) | ||
| */ |
There was a problem hiding this comment.
The terminology is binary vs. text. Then we probably need a means to get the current mode, so there's no escaping the API:
enum FileMode { text, binary }
void getMode(FileMode);
void setMode(FileMode);|
ping? |
|
sorry, guess I should have closed this. |
Especially for files that cannot be opened by the user in binary mode (like stdin and stdout), having only rawWrite and rawRead available is very limiting. To enable binary/raw file operation for stdin and stdout, the code to set those streams to binary mode is non-trivial. setRawMode() resolves this issue.