[Pkg] The Trunk: Files-ul.111.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Jul 16 10:20:51 UTC 2011


Levente Uzonyi uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-ul.111.mcz

==================== Summary ====================

Name: Files-ul.111
Author: ul
Time: 16 July 2011, 11:27:11.356 am
UUID: 42445191-7bd0-324c-bcca-079ee8b5da96
Ancestors: Files-ul.110

- FileStream class >> #detectFile:do: can accept a FileStream as it's first argument
- pass FileStreams instead of blocks to #detectFile:do:

=============== Diff against Files-ul.110 ===============

Item was changed:
  ----- Method: DirectoryEntryFile>>contentsFrom:to: (in category 'stream access') -----
  contentsFrom: startPosition to: endPosition 
  	"Answer my contents from startPosition to endPosition."
  	^ FileStream 
+ 		detectFile: self readStream
- 		detectFile: [ self readStream ]
  		do: 
  			[ : stream | 
  			stream
  				position: startPosition ;
  				next: endPosition - startPosition + 1 ]!

Item was changed:
  ----- Method: FileStream class>>detectFile:do: (in category 'instance creation') -----
+ detectFile: aBlockOrFileStream do: anotherBlock
+ 
+ 	^aBlockOrFileStream value "Assume that FileStreams return self for #value."
+ 		ifNotNil: [ :file | [ anotherBlock value: file ] ensure: [ file close ] ]!
- detectFile: aBlock do: anotherBlock
- 	^aBlock value
- 		ifNil: [nil]
-       	ifNotNil: [:file| [anotherBlock value: file] ensure: [file close]]!

Item was changed:
  ----- Method: FileStream class>>fileNamed:do: (in category 'instance creation') -----
  fileNamed: 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 fileNamed: fileName) do: aBlock!
- 	^ self detectFile: [ self fileNamed: fileName ] do: aBlock!

Item was changed:
  ----- Method: FileStream class>>forceNewFileNamed:do: (in category 'instance creation') -----
  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!
- 	^ self detectFile: [ self forceNewFileNamed: fileName ] do: aBlock!

Item was changed:
  ----- Method: FileStream class>>newFileNamed:do: (in category 'instance creation') -----
  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!
- 	^ self detectFile: [ self newFileNamed: fileName ] do: aBlock!

Item was changed:
  ----- Method: FileStream class>>oldFileNamed:do: (in category 'instance creation') -----
  oldFileNamed: 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 oldFileNamed: fileName) do: aBlock!
- 	^ self detectFile: [ self oldFileNamed: fileName ] do: aBlock!

Item was changed:
  ----- Method: FileStream class>>readOnlyFileNamed:do: (in category 'instance creation') -----
  readOnlyFileNamed: 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 readOnlyFileNamed: fileName) do: aBlock!
- 	^ self detectFile: [ self readOnlyFileNamed: fileName ] do: aBlock!



More information about the Packages mailing list