digitalmars.D.learn - setAttributes Issue.
Hi All, Request your help, can some one find what is the issue with the below code, as this is throwing the error "Access is denied". as the below code is supposed to to remove the read-only permission if set. Code: import std.algorithm; import std.array; import std.container.array; import std.datetime.systime; import std.file; import std.stdio; import std.typecons; auto coAgedDirClean (string FFs) { auto dFiles = Array!(Tuple!(string, SysTime))(dirEntries(join([`\\?\`, FFs]), SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name, a.timeCreated))); foreach(d; dFiles) { auto sDir = Array!string (dirEntries(d[0], SpanMode.depth).filter!(a => a.isDir && !a.isSymlink).map!(a => (a.name))); foreach(DirEntry sd; sDir) { import core.sys.windows.windows; if ((sd.attributes & FILE_ATTRIBUTE_READONLY) != 0) { setAttributes(sd, sd.attributes & ~FILE_ATTRIBUTE_READONLY); } rmdirRecurse(sd); }} dFiles.each!(f => rmdirRecurse(f[0])); return dFiles; } void main () { string FFs = "C:\\Temp\\SAPNAS1\\BACKUP1"; writeln(coAgedDirClean(FFs)[]); } From, Vino.B
Jul 15 2018
On Sunday, 15 July 2018 at 10:07:49 UTC, vino.B wrote:Hi All, Request your help, can some one find what is the issue with the below code, as this is throwing the error "Access is denied". as the below code is supposed to to remove the read-only permission if set. [...]Hi All, Was able to resolve this issue by removing the filter criteria auto sDir = Array!string (dirEntries(d[0], SpanMode.depth).filter!(a => !a.isSymlink) .map!(a => > (a.name))); From, Vino.B
Jul 15 2018