The Trunk: SMBase-nice.97.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: SMBase-nice.97.mcz

commits-2
Nicolas Cellier uploaded a new version of SMBase to project The Trunk:
http://source.squeak.org/trunk/SMBase-nice.97.mcz

==================== 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.
  fileName
  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!