[Pkg] Rio: File-Kernel-mtf.29.mcz

squeak-dev-noreply at lists.squeakfoundation.org squeak-dev-noreply at lists.squeakfoundation.org
Wed Jul 1 18:06:17 UTC 2009


A new version of File-Kernel was added to project Rio:
http://www.squeaksource.com/Rio/File-Kernel-mtf.29.mcz

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

Name: File-Kernel-mtf.29
Author: mtf
Time: 1 July 2009, 2:06:12 pm
UUID: dc4f3261-6669-11de-b5fb-001124e29fe6
Ancestors: File-Kernel-mtf.28

refactored the base, version, and extension utility methods to be able to handle padded version numbers

=============== Diff against File-Kernel-mtf.28 ===============

Item was changed:
  ----- Method: FileKernel>>splitToBaseVersionAndExt: (in category 'accessing') -----
  splitToBaseVersionAndExt: block
  
+ 	^ self splitToBaseVersionStringAndExt: [:b :v :e | block
+ 		value: b
+ 		value: (v ifNil: [0] ifNotNil: [v ifEmpty: [0] ifNotEmpty: [v asInteger]])
+ 		value: (e ifNil: [''])]!
- 	| fileName version ext period |
- 	
- 	fileName := self fileName.
- 	period := fileName lastIndexOf: $..
- 	((period <=1) | (period = fileName size)) ifTrue: [ ^ block value: fileName value: 0 value: '' ].
- 	 
- 	ext := fileName copyFrom: (period + 1) to: fileName size.
-  	fileName := fileName copyFrom: 1 to: period - 1.
- 	
- 	period := fileName lastIndexOf: $. ifAbsent: [ ^ block value: fileName value: 0 value: ext ].
- 	
- 	version := fileName copyFrom: period + 1 to: fileName size.
- 	version do: [ :char | char isDigit ifFalse: [ ^ block value: fileName value: 0 value: ext  ]].
- 		
- 	version := version asInteger.
- 	fileName := fileName copyFrom: 1 to: period - 1.
- 	
- 	^ block value: fileName value: version value: ext
- 	
- !

Item was changed:
  ----- Method: FileKernel>>base:version:ext: (in category 'accessing') -----
  base: newBase version: newVersion ext: newExt
  
  	"only changes non nil values"
  	
  	| base version ext |
  	
  	self splitToBaseVersionAndExt: [ :b :v :e |
+ 		base		:= newBase		ifNil: [ b ].
+ 		version		:= newVersion		ifNil: [ v ].
+ 		ext			:= newExt			ifNil: [ e ].
- 		base 	:= newBase 		ifNil: [ b ].
- 		version := newVersion 	ifNil: [ v ].
- 		ext 		:= newExt		ifNil: [ e ].
  	].
  		
+ 	self basicBase: base version: version ext: ext!
- 	self fileName: 
- 		(String streamContents: [ :str | 
- 			str nextPutAll: base. 
- 			version = 0 ifFalse: [ 
- 				str nextPut: $. ; nextPutAll: version asString 
- 			].
- 			ext notEmpty ifTrue: [ 
- 				str nextPut: $.; nextPutAll: ext 
- 			]
- 		]). 
- !

Item was added:
+ ----- Method: FileKernel>>basicBase:version:ext: (in category 'accessing') -----
+ basicBase: base version: version ext: ext
+ "Set my filename from the given base, version, and extension. version and extention may be nil; version may be an integer"
+ 
+ 	self fileName: (String streamContents: [ :str | 
+ 		str nextPutAll: base. 
+ 		version ifNotNil: [str nextPut: $.; nextPutAll: version asString].
+ 		ext ifNotNil: [str nextPut: $.; nextPutAll: ext]])!

Item was added:
+ ----- Method: FileKernel>>splitToBaseVersionStringAndExt: (in category 'accessing') -----
+ splitToBaseVersionStringAndExt: block
+ "Evaluates the block with three arguments: the base name of the file, its version as a string (if present), and its extension (if present). missing values are passed as nil. Unlike splitToBaseVersionAndExt, this method is lossless; a.ext, a..ext, a.0.ext, and a.00.ext can be distinguished"
+ 
+ 	| fileName version ext period |
+ 	
+ 	fileName := self fileName.
+ 	period := fileName lastIndexOf: $..
+ 	((period <=1) | (period = fileName size)) ifTrue: [ ^ block value: fileName value: nil value: nil ].
+ 	 
+ 	ext := fileName copyFrom: (period + 1) to: fileName size.
+  	fileName := fileName copyFrom: 1 to: period - 1.
+ 	
+ 	period := fileName lastIndexOf: $. ifAbsent: [ ^ block value: fileName value: nil value: ext ].
+ 	
+ 	version := fileName copyFrom: period + 1 to: fileName size.
+ 	version do: [ :char | char isDigit ifFalse: [ ^ block value: fileName value: nil value: ext  ]].
+ 		
+ 	fileName := fileName copyFrom: 1 to: period - 1.
+ 	
+ 	^ block value: fileName value: version value: ext!

Item was changed:
  ----- Method: FileKernel>>nextVersion (in category 'versions') -----
  nextVersion
+ "the next non-exisiting version (self if none)"
- 
- 	"the next non-exisiting version (self if none)"
  	
+ 	^ self copy version: ((self versions ifEmpty: [ ^ self ]) last + 1); yourself!
- ^ self copy base: nil version: ((self versions ifEmpty: [ ^ self ]) last + 1) ext: nil!



More information about the Packages mailing list