Advice on : rmdirRecurse and setAttributes in Windows

Vino vino.bheeman at hotmail.com
Sat Apr 21 18:39:02 UTC 2018


Hi All,

   The function rmdirRecurse does not work in Windows if the file 
has the READ ONLY permission, so to over come this issue, i have 
written the below function to set the permission on file and 
folder using the function "setAttributes" , so can any one advice 
me whether the below code is fine or what are the other ways to 
achieve the same.


auto aPrivileges(T)(T df)
if(df[0].isDir) {
             auto sDir = Array!string(dirEntries(join([`\\?\`, 
df[0]]), SpanMode.depth).filter!(a => a.isDir).map!(a => 
(a.name)));
             auto sFile = Array!string(dirEntries(join([`\\?\`, 
df[0]]), SpanMode.depth).filter!(a => a.isFile).map!(a => 
(a.name)));
             foreach(sD; parallel(sDir[], 1)) { 
setAttributes(sD.toUTF16, 66); }
             foreach(sF; parallel(sFile[], 1)) { 
setAttributes(sF.toUTF16, 666); }
             }
         else { setAttributes(df[0].toUTF16, 666); }
}

From,
Vino.B


More information about the Digitalmars-d-learn mailing list