Chris Muller uploaded a new version of Files to project The Trunk: http://source.squeak.org/trunk/Files-cmm.207.mcz
==================== Summary ====================
Name: Files-cmm.207 Author: cmm Time: 28 April 2024, 7:24:18.020282 pm UUID: 7f3afa72-a69e-48be-aae7-a50900bfd4a3 Ancestors: Files-ul.206
- Support #currentDirectoryNickname from FileDirectory class>>#on:. - Don't allow FileStream class>>#newFileNamed:do: and #forceNewFileNamed:do: to fail silently.
=============== Diff against Files-ul.206 ===============
Item was changed: ----- Method: FileDirectory class>>on: (in category 'instance creation') ----- on: pathString "Return a new file directory for the given path, of the appropriate FileDirectory subclass for the current OS platform."
| pathName | DirectoryClass ifNil: [self setDefaultDirectoryClass]. "If path ends with a delimiter (: or /) then remove it" pathName := pathString. (pathName at: pathName size ifAbsent: nil) = self pathNameDelimiter ifTrue: [pathName := pathName allButLast]. DirectoryClass parentDirectoryNickname ifNotNil: [:parentName| (pathName beginsWith: parentName) ifTrue: [pathName = parentName ifTrue: [^self default containingDirectory]. (pathName at: parentName size + 1 ifAbsent: nil) = self pathNameDelimiter ifTrue: [^self default containingDirectory on: (pathName allButFirst: parentName size + 1)]]]. + DirectoryClass currentDirectoryNickname ifNotNil: + [: currentName| + (pathName beginsWith: currentName) ifTrue: + [pathName = currentName ifTrue: + [^self default]. + (pathName at: currentName size + 1 ifAbsent: nil) = self pathNameDelimiter ifTrue: + [^self default on: (pathName allButFirst: currentName size + 1)]]]. + ^DirectoryClass new setPathName: pathName!
Item was changed: ----- Method: FileStream class>>forceNewFileNamed:do: (in category 'instance creation') ----- + forceNewFileNamed: fileName do: aBlock + "Create a file named fileName and value aBlock with a ReadWriteStream on its contents, which is closed automatically upon completion of aBlock. If the file identified by fileName already exists, it will be replaced. If the file can't be created for any reason, signal an error." + ^ (self forceNewFileNamed: fileName) + ifNil: [ self error: 'file not created' ] + ifNotNil: [ : fileStream | self detectFile: fileStream do: aBlock ]! - forceNewFileNamed: fileName do: aBlock - "Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.'' - - Returns the result of aBlock." - - ^self detectFile: (self forceNewFileNamed: fileName) do: aBlock!
Item was changed: ----- Method: FileStream class>>newFileNamed:do: (in category 'instance creation') ----- + newFileNamed: fileName do: aBlock + "Create a file named fileName and value aBlock with a ReadWriteStream on its contents, which is closed automatically upon completion of aBlock. If the file identified by fileName already exists, signal an error. If the file can't be created for any reason, signal an error." + ^ (self newFileNamed: fileName) + ifNil: [ self error: 'file not created' ] + ifNotNil: [ : fileStream | self detectFile: fileStream do: aBlock ]! - newFileNamed: fileName do: aBlock - "Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.'' - - Returns the result of aBlock." - - ^self detectFile: (self newFileNamed: fileName) do: aBlock!
packages@lists.squeakfoundation.org