[Lazarus] Removing read-only files in FileUtil.DeleteDirectory ?

Bart bartjunk64 at gmail.com
Mon Apr 30 12:45:45 CEST 2012


On 4/29/12, Juha Manninen <juha.manninen62 at gmail.com> wrote:

Removing files in windows can fail also.
The flag RemoveReadOnlyFiles actually means try to also remove
read-only files (just like DeleteDirectory actually tries to delete a
directory).
As long as the function returns False if removing of a file/dir fails
it should be OK.

I would change the declaration to:

function DeleteDirectory(const DirectoryName: string;
     OnlyChilds: boolean; const RemoveReadOnlyFiles: Boolean = False): boolean;

But that is possibly just a matter of taste.

One might also consider retuning the actual filename/foldername that
could not be removed if things fail, so feedback to the user can be
given.

Bart




More information about the Lazarus mailing list