On Sun, Aug 20, 2017 at 07:55:45PM +0200, Cyril Ferlicot D. wrote:
> Le 20/08/2017 ?? 19:53, Peter Uhn??k a ??crit :
> >
> > +1
> >
> > The only problem may be that even the VM doesn't actually know the
> > reason (it could just trigger the delete at vm-level which will just
> > return a failure state).
> >
> > Peter
>
> The fact that is touch the vm is a reason I post here. It would be good
> to have the advice of people knowing the FS management to know the best
> way to do this.
File deletion isn't handled directly by the VM, but by FilePlugin.
I consider myself a beginner at VM plugins, but since no-one else has
answered yet, my 2c:
Modifying the directory deletion code is not as easy as one would like since
there is a version per platform. At the moment there are six
(assuming I've counted correctly): win32, Mac OS, iOS, RiscOS, Plan9,
unix (iOS is a .m file, Objective-C presumably). However it looks like
it will still be reasonably straight-foward since the functions return a
boolean indicating success or failure, so it shouldn't be too difficult
to convert this to a status code. I might have a go at this
after my first plugin is accepted (but I can't make any promise).
If no-one else makes the change and you don't want to wait, there are a
couple of other options that don't require modification of the plugin:
1. Modify DiskStore>>delete: to check pre-conditions such as the
directory being empty. While this is probably safe for checking that
the directory is empty, for the more general case it is difficult
since it will need to take in to account any difference in behaviour
across platforms.
2. Modify the primitive failure handling code in
FilePluginPrims>>deleteDirectory: to take a
guess at why the primitive failed, e.g. is the directory empty.
I think this is the safer approach since at least we already know
that something has gone wrong.
Cheers,
Alistair