[squeak-dev] The Trunk: SMBase-nice.97.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Feb 25 03:20:03 UTC 2010

Nicolas Cellier uploaded a new version of SMBase to project The Trunk:

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

Name: SMBase-nice.97
Author: nice
Time: 25 February 2010, 4:20:11.041 am
UUID: d866a60a-74eb-fd4e-9453-b6a5c2d49296
Ancestors: SMBase-nice.96

Use FileDirectory>>#newFileNamed:do:

=============== Diff against SMBase-nice.96 ===============

Item was changed:
  ----- Method: SMAccount>>newFile:block: (in category 'files') -----
  newFile: fileName block: aBlock
  	"Create a new file. Let <aBlock> fill the file with content by calling it with a stream."
+ 	| dir |
- 	| dir stream |
  	dir := self uploadsDirectory.
+ 	(dir fileExists: fileName) ifTrue:[dir deleteFileNamed: fileName].
+ 	dir newFileNamed: fileName do: [:stream |
+ 		stream binary.
+ 		aBlock value: stream]!
- 	[(dir fileExists: fileName) ifTrue:[dir deleteFileNamed: fileName].
- 	stream := dir newFileNamed: fileName.
- 	stream binary.
- 	aBlock value: stream] ensure: [stream close]!

Item was changed:
  ----- Method: SMFileCache>>download: (in category 'services') -----
  download: aDownloadable 
  	"Download the file for this SMObject into the local file cache.
  	If the file already exists, delete it.
  	No unpacking or installation into the running image."
+ 	[ | dir fileName |
+ 	fileName := aDownloadable downloadFileName.
- 	[ | file dir fileName |fileName := aDownloadable downloadFileName.
  		ifNil: [self inform: 'No download url, can not download.'.
  			^ false].
  	fileName isEmpty
  		ifTrue: [self inform: 'Download url lacks filename, can not download.'.
  			^ false].
  	dir := aDownloadable cacheDirectory.
  	[ | stream |
  	stream := self getStream: aDownloadable.
  	stream ifNil: [^ false].
  	(dir fileExists: fileName)
  		ifTrue: [dir deleteFileNamed: fileName].
+ 	dir newFileNamed: fileName do: [:file | file binary; nextPutAll: stream contents]]]
- 	file := dir newFileNamed: fileName.
- 	file binary; nextPutAll: stream contents]
- 		ensure: [file ifNotNil: [file close]]]
  		on: Error
  		do: [^ false].
  	^ true!

More information about the Squeak-dev mailing list