What is the rationale behind std.file.setAttributes ?

Marco Leise Marco.Leise at gmx.de
Fri Dec 27 20:01:46 PST 2013


Am Sat, 28 Dec 2013 04:44:30 +0100
schrieb Marco Leise <Marco.Leise at gmx.de>:

> Am Sat, 28 Dec 2013 03:50:45 +0100
> schrieb Martin Nowak <code at dawg.eu>:
> 
> > On 12/27/2013 12:12 PM, Marco Leise wrote:
> > > 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.
> > 
> > Yep, totally ugly but it's the counterpart to
> > http://dlang.org/phobos/std_file.html#.getAttributes.
> > So if I save these attributes in a std.zip archive I was missing the 
> > possibility to restore them.
> 
> Hi, thanks for replying here. So .zip files store file
> attributes as ints? Then they must also have a data member
> that denotes the originating operating system, right?
> Otherwise it would be impossible to correctly restore a .zip
> file from one system on another. (Given relative path names
> and compatible file name character sets.)
> And the file attributes need to be converted between systems
> as well. Otherwise it would create *very* bizarre effects when
> applying POSIX chmod attributes on a Windows machine.

Ok, so there is a compatibility field for the file attributes
in a .zip file. So a .zip extractor has to version(Windows/Posix)
anyway to check if the attributes for a given file are
compatible with the host OS. Couldn't SetFileAttributes and
chmod be called right there on the spot?

-- 
Marco



More information about the Digitalmars-d mailing list