hmm.. i don't see if it will handle well a multiple extensions which sometimes is nice. (btw, why FS have to even care about it? a file name is a string. whatever you put there) Perhaps there should be two methods: one for adding extra extension (just unconditionally concatenate) and second for replacing extension #addExtension: + #changeExtension: (or #replaceExtension: ,if you want). Because what if i want to have extensions like .tar.gz? tarFile := (FSFilesystem disk workingDirectory / 'file.tar'). "zip stuff here" newName := tarFile addExtension: 'gz'. apparently new name should have .tar.gz extension while with current implementation of #withExtension: , it will replace the original one and put just .gz On 15 February 2012 19:42, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
OK, but don't hardcode the extensionDelimiter :)
Le 15 février 2012 16:20, Camillo Bruni <camillobruni@gmail.com> a écrit :
makes more sense to me On 2012-02-15, at 15:29, Esteban Lorenzano wrote:
hi,
FSPath>>#withExtension: Â is ignoring adding extension if extension is equal to end of basename.
For example, if I want to produce:
(FSFilesystem disk workingDirectory / 'Host') withExtension: 'st'.
I should receive:
/path/to/Host.st
but I actually receive:
/path/to/Host
that can be fixed replacing
FSPath>>#withExtension: extension    | basename name |    basename := self basename.    ^ (basename endsWith: extension)        ifTrue: [ self ]        ifFalse:            [name := basename copyUpToLast: self extensionDelimiter.            self withName: name extension: extension]
with:
FSPath>>#withExtension: extension    | basename name |    basename := self basename.    ^ (basename endsWith: '.', extension)        ifTrue: [ self ]        ifFalse:            [name := basename copyUpToLast: self extensionDelimiter.            self withName: name extension: extension]
but I don't know if that would be a good solution :)
best, Esteban
-- Best regards, Igor Stasenko.