What is the rationale behind std.file.setAttributes ?

Jonathan M Davis jmdavisProg at gmx.com
Sat Dec 28 00:18:22 PST 2013


On Saturday, December 28, 2013 07:21:28 Marco Leise wrote:
> schrieb Jonathan M Davis <jmdavisProg at gmx.com>:
> > We need to try hard to make Phobos cross-platform and portable, but some
> > stuff just can't be, and std.file already has some functions which fall
> > in that category (e.g. anything symlink related or dealing with file
> > times). And having a D wrapper around that functionality can make code
> > much cleaner, so I'm all for having a limited number of system-specific
> > functions in std.file if that's what it takes to get the job done (and
> > file permissions tend to fall in that category).
> > 
> > - Jonathan M Davis
> 
> But SetFileAttributes doesn't set file permissions (except for
> "read-only")! Chmod does. If you want a D wrapper for
> POSIX chmod in std.file, it should be exactly that. For
> Windows you need to work with ACLs to change permissions.

I'm not arguing the exact API for setFileAttributes, since I haven't spent the 
time as of yet to look it over and therefore do not feel qualified to comment 
on it specifically. My main point was that some stuff in std.file is system-
specific and that if it has to be, it's better to have it in std.file as system-
specific rather than not having it at all just because it couldn't be 
completely cross-platform and portable. So, just because setFileAttributes is 
doing something system-specific does not mean that it's bad. But its validity 
may very well be argued on other counts (e.g. whether it's actually a good API 
for what it does).

- Jonathan M Davis


More information about the Digitalmars-d mailing list