[Pharo-project] FileReference should throw error when deleting unexisting files?
Mariano Martinez Peck
marianopeck at gmail.com
Mon Jun 11 15:17:24 EDT 2012
On Mon, Jun 11, 2012 at 8:38 PM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:
> So if we now do:
> 'afileThatDoesntExist' asFileReference delete
> I get a PrimitiveFailed. If this is what we want, can I add:
> FileReference >> deleteIfExists
> self exists ifTrue: [ self delete]
So I discussed in IRC and Camillo and Sean recommended to use #ensureDelete
because it is concistent to ensureFile and ensureDirecotry etc...
for me #ensureDelete sounds the opposite to what this method does because I
am not ensuring anything, if fact, I won't remove anything if the file does
Camilo also suggested to do
FileReference >> deleteIfExists
self deleteIfAbsent: [ ]
FileReference >> deleteIfAbsent: aBlock
ifTrue: [self delete]
ifFalse: [aBock value]
What do you think? which one do you like more? #ensureDelete or
do you also agree to add the intermediate #deleteIfAbsent: ?
> or something like that? because lots of places (tearDown of tests) I
> want to remove crao which may or may not exist...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-dev