open, close, dup, dup2, lseek, read, write, fileno, etc.
Janice Caron
caron800 at googlemail.com
Fri Feb 8 21:57:19 PST 2008
- Previous message: open, close, dup, dup2, lseek, read, write, fileno, etc.
- Next message: open, close, dup, dup2, lseek, read, write, fileno, etc.
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
On 09/02/2008, Walter Bright <newshound1 at digitalmars.com> wrote:
> Going directly to the underlying OS functions makes for faster, more
> efficient I/O. Calling open, close, etc., on Windows makes for poor
> performance, because those functions are layered on top of the Windows
> I/O functions.
Thanks for the answer. Though my question wasn't "Why does
std.stream.File use them?", it was "Why can't I use them?", which is a
slightly different question, and I see no reason for prohibition.
It is simpler easier to write platform-independent code if you can use
open() and close(), because then you don't have to do
version(Windows) { h = wide ? CreateFileW() : CreateFileA(); }
version(linux) { h = open(); }
Platform independent code is also inherently easier to test, if you
don't happen to have a linux platform handy.
I wasn't complaining though - it is trivially easy to import those
functions with extern(C) so it's hardly a big deal. I was just
curious.
- Previous message: open, close, dup, dup2, lseek, read, write, fileno, etc.
- Next message: open, close, dup, dup2, lseek, read, write, fileno, etc.
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Digitalmars-d
mailing list