What is the rationale behind std.file.setAttributes ?

Marco Leise Marco.Leise at gmx.de
Fri Dec 27 03:12:29 PST 2013


I know that code is from Martin, and I don't mean this as
pointing with the finger. There are code reviews, too.

This is a case of the proverbial thin wrapper around a system
function, as public API of Phobos. Amongst the large set of
operating system abstractions, this one is somewhat deceiving,
because it looks the same on each platform, but the parameter
has a different meaning on each system. Instead of taking e.g.
octal!777 it should really be a D specific enum, IMHO. It is a
coincidence that both Windows and POSIX use a 32-bit integer
for file attributes, but not technically sound to confuse them
in a public API.

I'm posting this because concerning the parameter we have a
similar situation with our file mode specifiers, which are
forwarded to C library functions as is. Depending on the
platform they change their meaning as well. Although there
many standard flags, "don't inherit file handle in child
processes" has never been standardized and cannot be
retrofitted in Phobos right now, because we an enum wasn't
used in the first place. </rant>

-- 
Marco



More information about the Digitalmars-d mailing list