D is dead

Ecstatic Coder ecstatic.coder at gmail.com
Tue Sep 4 10:27:18 UTC 2018


On Tuesday, 4 September 2018 at 09:56:13 UTC, rikki cattermole 
wrote:
> On 04/09/2018 9:40 PM, Ecstatic Coder wrote:
>> But it seems that the latest version of "std.file.copy" now 
>> completely ignores the "PreserveAttributes.no" argument on 
>> Windows, which made recent Windows builds of Resync fail on 
>> read-only files.
>
> What???
>
> There is nothing in the changelog between 2.080.0 and 2.082.0 
> for changes to std.file.
>
> Version from July 2017[0]. Version from 2.082.0[1]. They look 
> the same to me.
>
> [0] 
> https://github.com/dlang/phobos/blob/d8959320e0c47a1861e32bbbf6a3ba30a019798e/std/file.d#L3430
> [1] 
> https://github.com/dlang/phobos/blob/v2.082.0/std/file.d#L4216

Mayb I'm wrong, but what I can say is that I've recently updated 
DMD and compiled a windows build of Resync, and that I *HAD* to 
make Windows-specific code that removes the "read-only" 
attributes only on Windows.

attributes = source_file_path.getAttributes();
source_file_path.getTimes( access_time, modification_time );

version ( Windows )
{
     if ( target_file_path.exists() )
     {
         target_file_path.setAttributes( attributes & ~1 );
     }

     source_file_path.copy( target_file_path, 
PreserveAttributes.no );
     target_file_path.setAttributes( attributes & ~1 );
     target_file_path.setTimes( access_time, modification_time );
     target_file_path.setAttributes( attributes );
}
else
{
     if ( target_file_path.exists() )
     {
         target_file_path.setAttributes( 511 );
     }

     source_file_path.copy( target_file_path, 
PreserveAttributes.no );
     target_file_path.setAttributes( attributes );
     target_file_path.setTimes( access_time, modification_time );
}

Honestly I don't see why I have to make this ugly fix on Windows, 
while the Linux version has always worked fine on read-only files.



More information about the Digitalmars-d mailing list