[Lazarus] RE : Removing read-only files in FileUtil.DeleteDirectory ?
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Apr 30 14:20:23 CEST 2012
On Mon, 30 Apr 2012 14:16:22 +0200
"Ludo Brands" <ludo.brands at free.fr> wrote:
> > Regarding issue #21855
> > http://bugs.freepascal.org/view.php?id=21855
> >
> > I am planning to reject the patch but I would like to have other
> > opinions, too.
>
> I'm in favor of patch with current definition (no default parameters as
> suggested by Bart) and with following ammendment:
>
> if RemoveReadOnlyFiles and ((FileInfo.Attr and faReadOnly)>0) then
> if FileSetAttrUTF8(CurFilename, FileInfo.Attr-faReadOnly) <> 0 then
> exit;
>
> Instead of
>
> if RemoveReadOnlyFiles and ((FileInfo.Attr and faReadOnly)>0) then
> FileSetAttrUTF8(CurFilename, FileInfo.Attr-faReadOnly);
>
> This way the function exits as soon as something goes wrong. No need
> iterating in directories when the attribute of the directory itself can't be
> changed.
How to find out what went wrong?
Maybe add parameter 'ExceptionOnError:boolean=false' and if true
then raise an exception with the file name.
Mattias
More information about the Lazarus
mailing list