Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
- Added #deleteIfAbsent: , #ensureDeleted and #ensureClosed. - Added #testDeleteIfAbsent, #testEnsureClosed, #testEnsureDeleted and #testExists. - Make FileSystemHandleTest >> tearDown more robust by using ensure* methods. I have know much about FileSystem so if someone can check please. I don't know if the classes where I place the unit tests are the correct place. http://code.google.com/p/pharo/issues/detail?id=6060 thanks On Tue, Jun 12, 2012 at 10:57 PM, Sean P. DeNigris wrote: > > Mariano Martinez Peck wrote > > > > Hi sean. It's time you update your image ;) > > ...does not work with > > Pharo2.0a > > Latest update: #20129 > > > > Ah yes. Now it's broken... I feel much better :) > > -- > View this message in context: > http://forum.world.st/FileReference-should-throw-error-when-deleting-unexisting-files-tp4634357p4634544.html > Sent from the Pharo Smalltalk mailing list archive at Nabble.com. > > -- Mariano http://marianopeck.wordpress.com
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
Mariano Martinez Peck wrote > > Hi sean. It's time you update your image ;) > ...does not work with > Pharo2.0a > Latest update: #20129 > Ah yes. Now it's broken... I feel much better :) -- View this message in context: http://forum.world.st/FileReference-should-throw-error-when-deleting-unexisting-files-tp4634357p4634544.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
Hi sean. It's time you update your image ;) the tests in latest images: works with Pharo2.0a Latest update: #20119 does not work with Pharo2.0a Latest update: #20129 problem is that (in the broken one) "reference openWritable: true" answers a handler with a NIL id will try to debug later. but if someone already have a hint... cheers On Tue, Jun 12, 2012 at 7:04 PM, Mariano Martinez Peck < marianop...@gmail.com> wrote: > > > On Tue, Jun 12, 2012 at 6:27 PM, Mariano Martinez Peck < > marianop...@gmail.com> wrote: > >> >> >> On Tue, Jun 12, 2012 at 6:07 PM, Sean P. DeNigris >> wrote: >> >>> >>> Mariano Martinez Peck wrote >>> > >>> > really??? i have just tried with that VM and I still get a false. Can >>> you >>> > try with a different name instead of 'plonk' ??? like >>> 'dasdasdasdasdasd' ? >>> > :) >>> >>> that worked too... I'm attaching >>> http://forum.world.st/file/n4634490/CogVM.zip the vm on Nabble . Just >>> to be >>> clear, you're highlighting the whole block and doing "PrintIt", right? >>> >> >> yes, I do that. >> Tried with that VM, same result. >> Just to clarify, the output of Smalltalk vm version is >> >> >> Smalltalk vm version 'CoInterpreter VMMaker-oscog-EstebanLorenzano.160 >> uuid: bec8cdf0-4e06-4975-8c02-e882fadf4df3 Jun 1 2012, >> StackToRegisterMappingCogit VMMaker-oscog-EstebanLorenzano.160 uuid: >> bec8cdf0-4e06-4975-8c02-e882fadf4df3 Jun 1 2012, >> https://git.gitorious.org/cogvm/blessed.git Commit: >> 2b16c2cfc16ef2e08dbc93113ce9552e810e3e78 Date: Wed May 30 16:16:27 2012 >> +0200 By: Esteban Lorenzano ' >> >> maybe this is because I am in snow leopard and you are in lion? >> >> > let's see something else. If you run all FileSystem tests, how many yellow > do you have? I have 4, one looking suspicious ;) > > 312 run, 308 passes, 0 expected failures, 4 failures, 0 errors, 0 > unexpected passes > Failures: > DiskFileSystemTest>>#testCopyDestExists > DiskFileSystemTest>>#testFile > DiskFileSystemTest>>#testRootIsNotAFile > FileHandleTest>>#testCreatedOpen > > Errors: > > > #testCreatedOpen is failing...maybe this is related > > > > >> >> -- >> Mariano >> http://marianopeck.wordpress.com >> >> > > > -- > Mariano > http://marianopeck.wordpress.com > > -- Mariano http://marianopeck.wordpress.com
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
On Tue, Jun 12, 2012 at 6:27 PM, Mariano Martinez Peck < marianop...@gmail.com> wrote: > > > On Tue, Jun 12, 2012 at 6:07 PM, Sean P. DeNigris > wrote: > >> >> Mariano Martinez Peck wrote >> > >> > really??? i have just tried with that VM and I still get a false. Can >> you >> > try with a different name instead of 'plonk' ??? like >> 'dasdasdasdasdasd' ? >> > :) >> >> that worked too... I'm attaching >> http://forum.world.st/file/n4634490/CogVM.zip the vm on Nabble . Just to >> be >> clear, you're highlighting the whole block and doing "PrintIt", right? >> > > yes, I do that. > Tried with that VM, same result. > Just to clarify, the output of Smalltalk vm version is > > > Smalltalk vm version 'CoInterpreter VMMaker-oscog-EstebanLorenzano.160 > uuid: bec8cdf0-4e06-4975-8c02-e882fadf4df3 Jun 1 2012, > StackToRegisterMappingCogit VMMaker-oscog-EstebanLorenzano.160 uuid: > bec8cdf0-4e06-4975-8c02-e882fadf4df3 Jun 1 2012, > https://git.gitorious.org/cogvm/blessed.git Commit: > 2b16c2cfc16ef2e08dbc93113ce9552e810e3e78 Date: Wed May 30 16:16:27 2012 > +0200 By: Esteban Lorenzano ' > > maybe this is because I am in snow leopard and you are in lion? > > let's see something else. If you run all FileSystem tests, how many yellow do you have? I have 4, one looking suspicious ;) 312 run, 308 passes, 0 expected failures, 4 failures, 0 errors, 0 unexpected passes Failures: DiskFileSystemTest>>#testCopyDestExists DiskFileSystemTest>>#testFile DiskFileSystemTest>>#testRootIsNotAFile FileHandleTest>>#testCreatedOpen Errors: #testCreatedOpen is failing...maybe this is related > > -- > Mariano > http://marianopeck.wordpress.com > > -- Mariano http://marianopeck.wordpress.com
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
On Tue, Jun 12, 2012 at 6:07 PM, Sean P. DeNigris wrote: > > Mariano Martinez Peck wrote > > > > really??? i have just tried with that VM and I still get a false. Can you > > try with a different name instead of 'plonk' ??? like 'dasdasdasdasdasd' > ? > > :) > > that worked too... I'm attaching > http://forum.world.st/file/n4634490/CogVM.zip the vm on Nabble . Just to > be > clear, you're highlighting the whole block and doing "PrintIt", right? > yes, I do that. Tried with that VM, same result. Just to clarify, the output of Smalltalk vm version is Smalltalk vm version 'CoInterpreter VMMaker-oscog-EstebanLorenzano.160 uuid: bec8cdf0-4e06-4975-8c02-e882fadf4df3 Jun 1 2012, StackToRegisterMappingCogit VMMaker-oscog-EstebanLorenzano.160 uuid: bec8cdf0-4e06-4975-8c02-e882fadf4df3 Jun 1 2012, https://git.gitorious.org/cogvm/blessed.git Commit: 2b16c2cfc16ef2e08dbc93113ce9552e810e3e78 Date: Wed May 30 16:16:27 2012 +0200 By: Esteban Lorenzano ' maybe this is because I am in snow leopard and you are in lion? -- Mariano http://marianopeck.wordpress.com
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
Mariano Martinez Peck wrote > > really??? i have just tried with that VM and I still get a false. Can you > try with a different name instead of 'plonk' ??? like 'dasdasdasdasdasd' ? > :) that worked too... I'm attaching http://forum.world.st/file/n4634490/CogVM.zip the vm on Nabble . Just to be clear, you're highlighting the whole block and doing "PrintIt", right? -- View this message in context: http://forum.world.st/FileReference-should-throw-error-when-deleting-unexisting-files-tp4634357p4634490.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
On Tue, Jun 12, 2012 at 3:39 PM, Sean P. DeNigris wrote: > > Mariano Martinez Peck wrote > > > > Now I found another problem > > > > | filesystem reference | > > filesystem := FileSystem store: DiskStore activeClass createDefault. > > reference := filesystem * 'plonk'. > > reference openWritable: true. > > reference exists > > > > -> answers false > > Answers true for me on Mac with this vm: > > https://ci.lille.inria.fr/pharo/view/Cog/job/Cog-VM/Architecture=32,OS=mac/lastSuccessfulBuild/artifact/Cog-mac.zip > > really??? i have just tried with that VM and I still get a false. Can you try with a different name instead of 'plonk' ??? like 'dasdasdasdasdasd' ? :) > -- > View this message in context: > http://forum.world.st/FileReference-should-throw-error-when-deleting-unexisting-files-tp4634357p4634473.html > Sent from the Pharo Smalltalk mailing list archive at Nabble.com. > > -- Mariano http://marianopeck.wordpress.com
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
Mariano Martinez Peck wrote > > Now I found another problem > > | filesystem reference | > filesystem := FileSystem store: DiskStore activeClass createDefault. > reference := filesystem * 'plonk'. > reference openWritable: true. > reference exists > > -> answers false Answers true for me on Mac with this vm: https://ci.lille.inria.fr/pharo/view/Cog/job/Cog-VM/Architecture=32,OS=mac/lastSuccessfulBuild/artifact/Cog-mac.zip -- View this message in context: http://forum.world.st/FileReference-should-throw-error-when-deleting-unexisting-files-tp4634357p4634473.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
Now I found another problem | filesystem reference | filesystem := FileSystem store: DiskStore activeClass createDefault. reference := filesystem * 'plonk'. reference openWritable: true. reference exists -> answers false, but | filesystem reference | filesystem := FileSystem memory. reference := filesystem * 'plonk'. reference openWritable: true. reference exists -> answers true. So...first, they should be polimorphic, right? second, which one is the correct? I guess in memory? thanks On Tue, Jun 12, 2012 at 11:45 AM, Stéphane Ducasse < stephane.duca...@inria.fr> wrote: > + 1 > > > he... I'm ok with that. But I want #deleteIfAbsent: :) > > > > -- Mariano http://marianopeck.wordpress.com
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
On 11.06.2012 20:38, Mariano Martinez Peck 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] or something like that? because lots of places (tearDown of tests) I want to remove crao which may or may not exist... thanks -- Mariano http://marianopeck.wordpress.com Is there any specific reason why you need to use setUp/tearDown instead of a more restricted scope? For scoped operations like tests, I always liked the XFileNamed: do: api, when you have references, how about: aFileReference tempFileDo: [:fileStream :canonicalPath (culled) |] Could be useful for command line interaction as well, I guess. Cheers, Henry
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
+ 1 > he... I'm ok with that. But I want #deleteIfAbsent: :) >
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
he... I'm ok with that. But I want #deleteIfAbsent: :) On Jun 12, 2012, at 9:57 AM, Mariano Martinez Peck wrote: > > > On Tue, Jun 12, 2012 at 9:54 AM, Esteban Lorenzano > wrote: > no, I vote for #deleteIfAbsent: too > > > fuc...I hate discussing in IRC. I won't do it again... > In IRC we said that even if I have #deleteIfAbsent: it is NOT enough. I don't > want to have to do > aReference deleteIfAbsent: [] all the time...I don't like it. So I want > #ensureDeleted or #deleteIfExists, and yes, it can rely on #deleteIfAbsent: > if desired, I don't care. > > cheers > > > On Jun 12, 2012, at 9:49 AM, Mariano Martinez Peck wrote: > >> Hi Stef. It looks we are minority. So today I will: >> - add #testExists (becuase it was broken but no test) >> - add #ensureDeleted >> - add #testEnsureDeleted >> - fix FileSystemHandleTest >> tearDown to #ensureDeleted the reference. >> >> cheers >> >> >> On Tue, Jun 12, 2012 at 7:25 AM, Stéphane Ducasse >> wrote: >> Yes to me ensureDelete or ensureDeleted is not explicit enough. I prefer >> remove/delete[ifAbsent:] >> On Jun 12, 2012, at 1:41 AM, Schwab,Wilhelm K wrote: >> >> > I generally default to saying "of course there should be an error." I >> > much prefer to get my bad news early rather than having to fish around or >> > it after the fact. Toward that end, I would recommend having >> > #deleteIfAbsent: and #delete that provides an error-raising block and >> > forwards to #deleteifAbsent:. That is consistent with collections, which >> > are not a bad model/source-of-inspiration for managing directory contents. >> > >> > Having #ensureDeleted in addition to above does no real harm. I would >> > prefer that the selector start with "delete" so it appears close to the >> > other methods in browsers, even w/o category filtering - makes it more >> > discoverable. >> > >> > Just my 2 asCents. >> > >> > Bill >> > >> > >> > ____________ >> > From: pharo-project-boun...@lists.gforge.inria.fr >> > [pharo-project-boun...@lists.gforge.inria.fr] on behalf of Chris >> > Cunningham [cunningham...@gmail.com] >> > Sent: Monday, June 11, 2012 5:55 PM >> > To: Pharo-project@lists.gforge.inria.fr >> > Subject: Re: [Pharo-project] FileReference should throw error when >> > deleting unexisting files? >> > >> > On Mon, Jun 11, 2012 at 2:32 PM, wrote: >> >> Maybe #ensureDeleted would be better? >> >> >> >> Nico >> > I like #ensureDeleted (make sure it doesn't exist) >> > >> > >> >> >> >> >> >> -- >> Mariano >> http://marianopeck.wordpress.com >> > > > > > -- > Mariano > http://marianopeck.wordpress.com >
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
On Tue, Jun 12, 2012 at 9:54 AM, Esteban Lorenzano wrote: > no, I vote for #deleteIfAbsent: too > > fuc...I hate discussing in IRC. I won't do it again... In IRC we said that even if I have #deleteIfAbsent: it is NOT enough. I don't want to have to do aReference deleteIfAbsent: [] all the time...I don't like it. So I want #ensureDeleted or #deleteIfExists, and yes, it can rely on #deleteIfAbsent: if desired, I don't care. cheers > On Jun 12, 2012, at 9:49 AM, Mariano Martinez Peck wrote: > > Hi Stef. It looks we are minority. So today I will: > - add #testExists (becuase it was broken but no test) > - add #ensureDeleted > - add #testEnsureDeleted > - fix FileSystemHandleTest >> tearDown to #ensureDeleted the reference. > > cheers > > > On Tue, Jun 12, 2012 at 7:25 AM, Stéphane Ducasse < > stephane.duca...@inria.fr> wrote: > >> Yes to me ensureDelete or ensureDeleted is not explicit enough. I prefer >> remove/delete[ifAbsent:] >> On Jun 12, 2012, at 1:41 AM, Schwab,Wilhelm K wrote: >> >> > I generally default to saying "of course there should be an error." I >> much prefer to get my bad news early rather than having to fish around or >> it after the fact. Toward that end, I would recommend having >> #deleteIfAbsent: and #delete that provides an error-raising block and >> forwards to #deleteifAbsent:. That is consistent with collections, which >> are not a bad model/source-of-inspiration for managing directory contents. >> > >> > Having #ensureDeleted in addition to above does no real harm. I would >> prefer that the selector start with "delete" so it appears close to the >> other methods in browsers, even w/o category filtering - makes it more >> discoverable. >> > >> > Just my 2 asCents. >> > >> > Bill >> > >> > >> > >> > From: pharo-project-boun...@lists.gforge.inria.fr [ >> pharo-project-boun...@lists.gforge.inria.fr] on behalf of Chris >> Cunningham [cunningham...@gmail.com] >> > Sent: Monday, June 11, 2012 5:55 PM >> > To: Pharo-project@lists.gforge.inria.fr >> > Subject: Re: [Pharo-project] FileReference should throw error when >> deleting unexisting files? >> > >> > On Mon, Jun 11, 2012 at 2:32 PM, wrote: >> >> Maybe #ensureDeleted would be better? >> >> >> >> Nico >> > I like #ensureDeleted (make sure it doesn't exist) >> > >> > >> >> >> > > > -- > Mariano > http://marianopeck.wordpress.com > > > -- Mariano http://marianopeck.wordpress.com
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
no, I vote for #deleteIfAbsent: too On Jun 12, 2012, at 9:49 AM, Mariano Martinez Peck wrote: > Hi Stef. It looks we are minority. So today I will: > - add #testExists (becuase it was broken but no test) > - add #ensureDeleted > - add #testEnsureDeleted > - fix FileSystemHandleTest >> tearDown to #ensureDeleted the reference. > > cheers > > > On Tue, Jun 12, 2012 at 7:25 AM, Stéphane Ducasse > wrote: > Yes to me ensureDelete or ensureDeleted is not explicit enough. I prefer > remove/delete[ifAbsent:] > On Jun 12, 2012, at 1:41 AM, Schwab,Wilhelm K wrote: > > > I generally default to saying "of course there should be an error." I much > > prefer to get my bad news early rather than having to fish around or it > > after the fact. Toward that end, I would recommend having #deleteIfAbsent: > > and #delete that provides an error-raising block and forwards to > > #deleteifAbsent:. That is consistent with collections, which are not a bad > > model/source-of-inspiration for managing directory contents. > > > > Having #ensureDeleted in addition to above does no real harm. I would > > prefer that the selector start with "delete" so it appears close to the > > other methods in browsers, even w/o category filtering - makes it more > > discoverable. > > > > Just my 2 asCents. > > > > Bill > > > > > > > > From: pharo-project-boun...@lists.gforge.inria.fr > > [pharo-project-boun...@lists.gforge.inria.fr] on behalf of Chris Cunningham > > [cunningham...@gmail.com] > > Sent: Monday, June 11, 2012 5:55 PM > > To: Pharo-project@lists.gforge.inria.fr > > Subject: Re: [Pharo-project] FileReference should throw error when deleting > > unexisting files? > > > > On Mon, Jun 11, 2012 at 2:32 PM, wrote: > >> Maybe #ensureDeleted would be better? > >> > >> Nico > > I like #ensureDeleted (make sure it doesn't exist) > > > > > > > > > > -- > Mariano > http://marianopeck.wordpress.com >
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
Hi Stef. It looks we are minority. So today I will: - add #testExists (becuase it was broken but no test) - add #ensureDeleted - add #testEnsureDeleted - fix FileSystemHandleTest >> tearDown to #ensureDeleted the reference. cheers On Tue, Jun 12, 2012 at 7:25 AM, Stéphane Ducasse wrote: > Yes to me ensureDelete or ensureDeleted is not explicit enough. I prefer > remove/delete[ifAbsent:] > On Jun 12, 2012, at 1:41 AM, Schwab,Wilhelm K wrote: > > > I generally default to saying "of course there should be an error." I > much prefer to get my bad news early rather than having to fish around or > it after the fact. Toward that end, I would recommend having > #deleteIfAbsent: and #delete that provides an error-raising block and > forwards to #deleteifAbsent:. That is consistent with collections, which > are not a bad model/source-of-inspiration for managing directory contents. > > > > Having #ensureDeleted in addition to above does no real harm. I would > prefer that the selector start with "delete" so it appears close to the > other methods in browsers, even w/o category filtering - makes it more > discoverable. > > > > Just my 2 asCents. > > > > Bill > > > > > > > > From: pharo-project-boun...@lists.gforge.inria.fr [ > pharo-project-boun...@lists.gforge.inria.fr] on behalf of Chris > Cunningham [cunningham...@gmail.com] > > Sent: Monday, June 11, 2012 5:55 PM > > To: Pharo-project@lists.gforge.inria.fr > > Subject: Re: [Pharo-project] FileReference should throw error when > deleting unexisting files? > > > > On Mon, Jun 11, 2012 at 2:32 PM, wrote: > >> Maybe #ensureDeleted would be better? > >> > >> Nico > > I like #ensureDeleted (make sure it doesn't exist) > > > > > > > -- Mariano http://marianopeck.wordpress.com
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
Yes to me ensureDelete or ensureDeleted is not explicit enough. I prefer remove/delete[ifAbsent:] On Jun 12, 2012, at 1:41 AM, Schwab,Wilhelm K wrote: > I generally default to saying "of course there should be an error." I much > prefer to get my bad news early rather than having to fish around or it after > the fact. Toward that end, I would recommend having #deleteIfAbsent: and > #delete that provides an error-raising block and forwards to > #deleteifAbsent:. That is consistent with collections, which are not a bad > model/source-of-inspiration for managing directory contents. > > Having #ensureDeleted in addition to above does no real harm. I would prefer > that the selector start with "delete" so it appears close to the other > methods in browsers, even w/o category filtering - makes it more discoverable. > > Just my 2 asCents. > > Bill > > > > From: pharo-project-boun...@lists.gforge.inria.fr > [pharo-project-boun...@lists.gforge.inria.fr] on behalf of Chris Cunningham > [cunningham...@gmail.com] > Sent: Monday, June 11, 2012 5:55 PM > To: Pharo-project@lists.gforge.inria.fr > Subject: Re: [Pharo-project] FileReference should throw error when deleting > unexisting files? > > On Mon, Jun 11, 2012 at 2:32 PM, wrote: >> Maybe #ensureDeleted would be better? >> >> Nico > I like #ensureDeleted (make sure it doesn't exist) > >
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
I generally default to saying "of course there should be an error." I much prefer to get my bad news early rather than having to fish around or it after the fact. Toward that end, I would recommend having #deleteIfAbsent: and #delete that provides an error-raising block and forwards to #deleteifAbsent:. That is consistent with collections, which are not a bad model/source-of-inspiration for managing directory contents. Having #ensureDeleted in addition to above does no real harm. I would prefer that the selector start with "delete" so it appears close to the other methods in browsers, even w/o category filtering - makes it more discoverable. Just my 2 asCents. Bill From: pharo-project-boun...@lists.gforge.inria.fr [pharo-project-boun...@lists.gforge.inria.fr] on behalf of Chris Cunningham [cunningham...@gmail.com] Sent: Monday, June 11, 2012 5:55 PM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] FileReference should throw error when deleting unexisting files? On Mon, Jun 11, 2012 at 2:32 PM, wrote: > Maybe #ensureDeleted would be better? > > Nico I like #ensureDeleted (make sure it doesn't exist)
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
Chris Cunningham wrote > > I like #ensureDeleted (make sure it doesn't exist) > Makes sense... +1 -- View this message in context: http://forum.world.st/FileReference-should-throw-error-when-deleting-unexisting-files-tp4634357p4634396.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
On Mon, Jun 11, 2012 at 2:32 PM, wrote: > Maybe #ensureDeleted would be better? > > Nico I like #ensureDeleted (make sure it doesn't exist)
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
Mariano Martinez Peck writes: > On Mon, Jun 11, 2012 at 8:38 PM, Mariano Martinez Peck > 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 not exist. I like #ensureDelete, because yes, it is consistent. I see it as "make sure the file is deleted", so it makes sense to me. Maybe #ensureDeleted would be better? Nico > Camilo also suggested to do > > > FileReference >> deleteIfExists > > self deleteIfAbsent: [ ] > > > FileReference >> deleteIfAbsent: aBlock > > self exists > ifTrue: [self delete] > ifFalse: [aBock value] > > > What do you think? which one do you like more? #ensureDelete or > #deleteIfExists? > do you also agree to add the intermediate #deleteIfAbsent: ? > > Cheers > > > > > or something like that? because lots of places (tearDown of > tests) I want to remove crao which may or may not exist... > > thanks > > -- > Mariano > http://marianopeck.wordpress.com -- Nicolas Petton http://nicolas-petton.fr
Re: [Pharo-project] FileReference should throw error when deleting unexisting files?
On Mon, Jun 11, 2012 at 8:38 PM, Mariano Martinez Peck < marianop...@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 not exist. Camilo also suggested to do FileReference >> deleteIfExists self deleteIfAbsent: [ ] FileReference >> deleteIfAbsent: aBlock self exists ifTrue: [self delete] ifFalse: [aBock value] What do you think? which one do you like more? #ensureDelete or #deleteIfExists? do you also agree to add the intermediate #deleteIfAbsent: ? Cheers > or something like that? because lots of places (tearDown of tests) I > want to remove crao which may or may not exist... > > thanks > > -- > Mariano > http://marianopeck.wordpress.com > > -- Mariano http://marianopeck.wordpress.com