Re: [Pharo-users] ensureCreateFile
Hi ! I made this if it's ok for you i'll post it on fogbugs : AbstractFileReference createFile "Create if necessary a file for the receiver. If the parent does not exist return an exception" self parent ensureCreateDirectory. self writeStream close. createDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents does not exist return an exception" self parent exists ifFalse:[self error:'The parent directory does not exist']. ^ self resolve ensureCreateDirectory ensureCreateFile "Create if necessary a file for the receiver. If the parent does not exist creates it" self parent ensureCreateDirectory. self writeStream close. ensureCreateDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents folder does not exist create it" ^ self resolve ensureCreateDirectory 2016-04-26 10:34 GMT+02:00 Valentin Ryckewaert < valentin.ryckewaert@gmail.com>:
Hi !
I made this if it's ok for you i'll post it on fogbugs :
AbstractFileReference createFile "Create if necessary a file for the receiver. If the parent does not exist return an exception" self parent ensureCreateDirectory. self writeStream close. createDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents does not exist return an exception" self parent exists ifFalse:[self error:'The parent directory does not exist']. ^ self resolve ensureCreateDirectory ensureCreateFile "Create if necessary a file for the receiver. If the parent does not exist creates it" self parent ensureCreateDirectory. self writeStream close. ensureCreateDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents folder does not exist create it" ^ self resolve ensureCreateDirectory
2016-04-25 16:28 GMT+02:00 Stéphane Ducasse <stephane.ducasse@inria.fr>:
oui moi aussi je me demandais si on devait introduire une autre methode mais en fait le nouveau comportement est compatible donc je le ferais.
On 25 Apr 2016, at 13:58, Valentin Ryckewaert < valentin.ryckewaert@gmail.com> wrote:
Tu en penses quoi toi ? Je trouve ça illogique que ensureCreate ne signifie pas la meme chose pour un dossier ou pour un fichier.
---------- Forwarded message ---------- From: Valentin Ryckewaert <valentin.ryckewaert@gmail.com> Date: 2016-04-22 10:11 GMT+02:00 Subject: Re: [Pharo-users] ensureCreateFile To: Any question about pharo is welcome <pharo-users@lists.pharo.org>
For me ensureCreateFolder is made to be sure the folder is created, if you make '/home/a/b/c/d' with a b c d not existing it will create all of them. ensureCreateFile should do the same thing no ?
2016-04-21 13:19 GMT+02:00 Peter Uhnák <i.uhnak@gmail.com>:
because it's like this
ensureCreateFolder : create the folder structure if necessary ensureCreateFile : create the file if necessary
I really don't see any gain from changing existing behavior and introducing potential problems. If I ask for file to be created, I don't expect that the system will suddenly start creating folders, that's a unintentional side effect. If you need it for your convenience, then it's dead-easy to implement without breaking existing stuff.
On Thu, Apr 21, 2016 at 10:35 AM, Denis Kudriashov <dionisiydk@gmail.com
wrote:
2016-04-21 9:55 GMT+02:00 Valentin Ryckewaert < valentin.ryckewaert@gmail.com>:
Yes but why ensureCreateFile then ? Why don't we juste create a message createFile as there is createFolder ? createFolder : create the folder createFile : create the file
ensureCreateFolder : create the folder and its parents if necessary ensureCreateFile : create the file and its parents if necessary
+1
-------------------------------------------- Stéphane Ducasse http://stephane.ducasse.free.fr http://www.synectique.eu / http://www.pharo.org 03 59 35 87 52 Assistant: Julie Jonas 03 59 57 78 50 03 59 35 86 16
S. Ducasse - Inria 40, avenue Halley, Parc Scientifique de la Haute Borne, Bât.A, Park Plaza Villeneuve d'Ascq 59650 France
AbstractFileReference createFile "Create if necessary a file for the receiver. If the parent does not exist return an exception" self parent ensureCreateDirectory. self writeStream close.
ensureCreateFile "Create if necessary a file for the receiver. If the parent does not exist creates it" self parent ensureCreateDirectory. self writeStream close.
I don't see any difference in the implementation. Wrong copy/paste? But from the comments I am for it. :)
2016-04-26 10:34 GMT+02:00 Valentin Ryckewaert < valentin.ryckewaert@gmail.com>:
createFile "Create if necessary a file for the receiver. If the parent does not exist return an exception" self parent ensureCreateDirectory. self writeStream close.
But it is wrong? It same as ensureCreateFile
Hi, https://pharo.fogbugz.com/f/cases/18084/FileReference-EnsureCreateFile the issue report I just corrected it in the slice Peter, sorry for my mistake. 2016-04-26 10:34 GMT+02:00 Valentin Ryckewaert < valentin.ryckewaert@gmail.com>:
Hi !
I made this if it's ok for you i'll post it on fogbugs :
AbstractFileReference createFile "Create if necessary a file for the receiver. If the parent does not exist return an exception" self parent ensureCreateDirectory. self writeStream close. createDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents does not exist return an exception" self parent exists ifFalse:[self error:'The parent directory does not exist']. ^ self resolve ensureCreateDirectory ensureCreateFile "Create if necessary a file for the receiver. If the parent does not exist creates it" self parent ensureCreateDirectory. self writeStream close. ensureCreateDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents folder does not exist create it" ^ self resolve ensureCreateDirectory
2016-04-26 10:34 GMT+02:00 Valentin Ryckewaert < valentin.ryckewaert@gmail.com>:
Hi !
I made this if it's ok for you i'll post it on fogbugs :
AbstractFileReference createFile "Create if necessary a file for the receiver. If the parent does not exist return an exception" self parent ensureCreateDirectory. self writeStream close. createDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents does not exist return an exception" self parent exists ifFalse:[self error:'The parent directory does not exist']. ^ self resolve ensureCreateDirectory ensureCreateFile "Create if necessary a file for the receiver. If the parent does not exist creates it" self parent ensureCreateDirectory. self writeStream close. ensureCreateDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents folder does not exist create it" ^ self resolve ensureCreateDirectory
2016-04-25 16:28 GMT+02:00 Stéphane Ducasse <stephane.ducasse@inria.fr>:
oui moi aussi je me demandais si on devait introduire une autre methode mais en fait le nouveau comportement est compatible donc je le ferais.
On 25 Apr 2016, at 13:58, Valentin Ryckewaert < valentin.ryckewaert@gmail.com> wrote:
Tu en penses quoi toi ? Je trouve ça illogique que ensureCreate ne signifie pas la meme chose pour un dossier ou pour un fichier.
---------- Forwarded message ---------- From: Valentin Ryckewaert <valentin.ryckewaert@gmail.com> Date: 2016-04-22 10:11 GMT+02:00 Subject: Re: [Pharo-users] ensureCreateFile To: Any question about pharo is welcome <pharo-users@lists.pharo.org>
For me ensureCreateFolder is made to be sure the folder is created, if you make '/home/a/b/c/d' with a b c d not existing it will create all of them. ensureCreateFile should do the same thing no ?
2016-04-21 13:19 GMT+02:00 Peter Uhnák <i.uhnak@gmail.com>:
because it's like this
ensureCreateFolder : create the folder structure if necessary ensureCreateFile : create the file if necessary
I really don't see any gain from changing existing behavior and introducing potential problems. If I ask for file to be created, I don't expect that the system will suddenly start creating folders, that's a unintentional side effect. If you need it for your convenience, then it's dead-easy to implement without breaking existing stuff.
On Thu, Apr 21, 2016 at 10:35 AM, Denis Kudriashov < dionisiydk@gmail.com> wrote:
2016-04-21 9:55 GMT+02:00 Valentin Ryckewaert < valentin.ryckewaert@gmail.com>:
Yes but why ensureCreateFile then ? Why don't we juste create a message createFile as there is createFolder ? createFolder : create the folder createFile : create the file
ensureCreateFolder : create the folder and its parents if necessary ensureCreateFile : create the file and its parents if necessary
+1
-------------------------------------------- Stéphane Ducasse http://stephane.ducasse.free.fr http://www.synectique.eu / http://www.pharo.org 03 59 35 87 52 Assistant: Julie Jonas 03 59 57 78 50 03 59 35 86 16
S. Ducasse - Inria 40, avenue Halley, Parc Scientifique de la Haute Borne, Bât.A, Park Plaza Villeneuve d'Ascq 59650 France
On 26/04/2016 10:34, Valentin Ryckewaert wrote:
Hi !
I made this if it's ok for you i'll post it on fogbugs :
AbstractFileReference createFile "Create if necessary a file for the receiver. If the parent does not exist return an exception" self parent ensureCreateDirectory. self writeStream close. createDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents does not exist return an exception" self parent exists ifFalse:[self error:'The parent directory does not exist']. ^ self resolve ensureCreateDirectory ensureCreateFile "Create if necessary a file for the receiver. If the parent does not exist creates it" self parent ensureCreateDirectory. self writeStream close. ensureCreateDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents folder does not exist create it" ^ self resolve ensureCreateDirectory
Hi, I think that createDirectory should raise a FileDoesNotExist instead of an Exception. BTW, this may be good to discuss in another issue but we have a FileDoesNotExistException and a FileDoesNotExist in the image. Maybe we can unify both? Or if there is a difference we can explain it in the class comment because I don't see the difference. -- Cyril Ferlicot http://www.synectique.eu 165 Avenue Bretagne Lille 59000 France
I used this because here it's the folder which doesn't exist so I didn't know if FileDoesNotExist were a good idea, here it's as you want. 2016-04-26 11:24 GMT+02:00 Cyril Ferlicot Delbecque < cyril.ferlicot@gmail.com>:
On 26/04/2016 10:34, Valentin Ryckewaert wrote:
Hi !
I made this if it's ok for you i'll post it on fogbugs :
AbstractFileReference createFile "Create if necessary a file for the receiver. If the parent does not exist return an exception" self parent ensureCreateDirectory. self writeStream close. createDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents does not exist return an exception" self parent exists ifFalse:[self error:'The parent directory does not exist']. ^ self resolve ensureCreateDirectory ensureCreateFile "Create if necessary a file for the receiver. If the parent does not exist creates it" self parent ensureCreateDirectory. self writeStream close. ensureCreateDirectory "Verifies that the directory does not exist and only creates if necessary. Do not remove files contained if they exist.If the parents folder does not exist create it" ^ self resolve ensureCreateDirectory
Hi,
I think that createDirectory should raise a FileDoesNotExist instead of an Exception.
BTW, this may be good to discuss in another issue but we have a FileDoesNotExistException and a FileDoesNotExist in the image. Maybe we can unify both? Or if there is a difference we can explain it in the class comment because I don't see the difference.
-- Cyril Ferlicot
165 Avenue Bretagne Lille 59000 France
On 26/04/2016 11:31, Valentin Ryckewaert wrote:
I used this because here it's the folder which doesn't exist so I didn't know if FileDoesNotExist were a good idea, here it's as you want.
In Unix (at least) a directory is a file. I don't know if it's the same in Windows. So in my opinion it's a good idea to raise a "FileDoesNotExist". -- Cyril Ferlicot http://www.synectique.eu 165 Avenue Bretagne Lille 59000 France
Why not make a subclass of FileDoesNotExist, DirectoryDoesNotExist - it is almost the same, but more specific. Good exceptions are really important.
On 26 Apr 2016, at 11:44, Cyril Ferlicot Delbecque <cyril.ferlicot@gmail.com> wrote:
On 26/04/2016 11:31, Valentin Ryckewaert wrote:
I used this because here it's the folder which doesn't exist so I didn't know if FileDoesNotExist were a good idea, here it's as you want.
In Unix (at least) a directory is a file. I don't know if it's the same in Windows. So in my opinion it's a good idea to raise a "FileDoesNotExist".
-- Cyril Ferlicot
165 Avenue Bretagne Lille 59000 France
On 26/04/2016 11:31, Valentin Ryckewaert wrote:
I used this because here it's the folder which doesn't exist so I didn't know if FileDoesNotExist were a good idea, here it's as you want.
In fact I did not see but there is also a DirectoryDoesNotExist :) -- Cyril Ferlicot http://www.synectique.eu 165 Avenue Bretagne Lille 59000 France
On 26 Apr 2016, at 11:49, Cyril Ferlicot Delbecque <cyril.ferlicot@gmail.com> wrote:
On 26/04/2016 11:31, Valentin Ryckewaert wrote:
I used this because here it's the folder which doesn't exist so I didn't know if FileDoesNotExist were a good idea, here it's as you want.
In fact I did not see but there is also a DirectoryDoesNotExist :)
Dub, I should have looked first ;-)
-- Cyril Ferlicot
165 Avenue Bretagne Lille 59000 France
I sent a new slice, check it and say me if it's ok for you :) 2016-04-26 11:51 GMT+02:00 Sven Van Caekenberghe <sven@stfx.eu>:
On 26 Apr 2016, at 11:49, Cyril Ferlicot Delbecque < cyril.ferlicot@gmail.com> wrote:
On 26/04/2016 11:31, Valentin Ryckewaert wrote:
I used this because here it's the folder which doesn't exist so I didn't know if FileDoesNotExist were a good idea, here it's as you want.
In fact I did not see but there is also a DirectoryDoesNotExist :)
Dub, I should have looked first ;-)
-- Cyril Ferlicot
165 Avenue Bretagne Lille 59000 France
participants (5)
-
Cyril Ferlicot Delbecque -
Denis Kudriashov -
Peter Uhnák -
Sven Van Caekenberghe -
Valentin Ryckewaert