[squeak-dev] The Trunk: Files-jcg.27.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Sep 1 07:56:19 UTC 2009


Joshua Gargus uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-jcg.27.mcz

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

Name: Files-jcg.27
Author: jcg
Time: 1 September 2009, 12:56:15 pm
UUID: 1b72224b-d639-44fc-b7ef-3ea1d359f682
Ancestors: Files-ar.26

RemoteString>>checkSum: relied on broken behavior in #mimeEncode:  (see Collections-jcg.124).  Fixed this assumption, and simplified the code at the same time.

=============== Diff against Files-ar.26 ===============

Item was changed:
  ----- Method: RemoteString>>checkSum: (in category 'private') -----
  checkSum: aString
  	"Construct a checksum of the string.  A three byte number represented as Base64 characters."
+ 	| sum shift bytes |
+ 	sum := aString size.
+ 	shift := 0.
+ 	aString do: [:char |
+ 		(shift := shift + 7) > 16 ifTrue: [shift := shift - 17].
+ 			"shift by 7 to keep a change of adjacent chars from xoring to same value"
+ 		sum := sum bitXor: (char asInteger bitShift: shift)
+ 	].
+ 	bytes := ByteArray new: 3.
+ 	sum := sum + 16r10000000000.
+ 	1 to: 3 do: [:ind | bytes at: ind put: (sum digitAt: ind)].
+ 	^bytes base64Encoded!
- 
- | sum shift bytes ss bb |
- sum := aString size.
- shift := 0.
- aString do: [:char |
- 	(shift := shift + 7) > 16 ifTrue: [shift := shift - 17].
- 		"shift by 7 to keep a change of adjacent chars from xoring to same value"
- 	sum := sum bitXor: (char asInteger bitShift: shift)].
- bytes := ByteArray new: 3.
- sum := sum + 16r10000000000.
- 1 to: 3 do: [:ind | bytes at: ind put: (sum digitAt: ind)].
- ss := ReadWriteStream on: (ByteArray new: 3).
- ss nextPutAll: bytes.
- bb := Base64MimeConverter mimeEncode: ss.
- ^ bb contents!

Item was changed:
  StandardFileStream subclass: #CrLfFileStream
  	instanceVariableNames: 'lineEndConvention'
+ 	classVariableNames: 'Cr CrLf Lf LineEndDefault LineEndStrings LookAheadCount'
- 	classVariableNames: 'LookAheadCount LineEndDefault LineEndStrings CrLf Cr Lf'
  	poolDictionaries: ''
  	category: 'Files-Kernel'!
  
  !CrLfFileStream commentStamp: 'ls 11/10/2002 13:32' prior: 0!
  I am the same as a regular file stream, except that when I am in text mode, I will automatically convert line endings between the underlying platform's convention, and Squeak's convention of carriage-return only.  The goal is that Squeak text files can be treated as OS text files, and vice versa.
  
  In binary mode, I behave identically to a StandardFileStream.
  
  To enable CrLfFileStream as the default file stream class for an entire image, modify FileStream class concreteStream .
  
  
  There are two caveats on programming with CrLfFileStream.
  
  First, the choice of text mode versus binary mode affects which characters are visible in Squeak, and no longer just affects whether those characters are returned as Character's or as Integer's.  Thus the choice of mode needs to be made very carefully, and must be based on intent instead of convenience of representation.  The methods asString, asByteArray, asCharacter, and asInteger can be used to convert between character and integer representations.  (Arguably, file streams should accept either strings or characters in nextPut: and nextPutAll:, but that is not the case right now.)
  
  Second, arithmetic on positions no longer works, because one character that Squeak sees (carriage return) could map to two characters in the underlying file (carriage return plus line feed, on MS Windows and MS DOS).  Comparison between positions still works.  (This caveat could perhaps be fixed by maintaining a map between Squeak positions and positions in the underlying file, but it is complicated.  Consider, for example, updates to the middle of the file.  Also, consider that text files are rarely updated in the middle of the file, and that general random access to a text file is rarely very useful.  If general random access with specific file counts is desired, then the file is starting to sound like a binary file instead of a text file.)
  
  !

Item was changed:
  Object subclass: #FileDirectory
  	instanceVariableNames: 'pathName'
+ 	classVariableNames: 'DefaultDirectory DirectoryClass StandardMIMEMappings'
- 	classVariableNames: 'StandardMIMEMappings DirectoryClass DefaultDirectory'
  	poolDictionaries: ''
  	category: 'Files-Directories'!
  
  !FileDirectory commentStamp: '<historical>' prior: 0!
  A FileDirectory represents a folder or directory in the underlying platform's file system. It carries a fully-qualified path name for the directory it represents, and can enumerate the files and directories within that directory.
  
  A FileDirectory can be thought of as a Dictionary whose keys are the local names of files in that directory, and whose values are directory "entries". Each entry is an array of five items:
  
  	<name> <creationTime> <modificationTime> <dirFlag> <fileSize>
  
  The times are given in seconds, and can be converted to a time and date via Time>dateAndTimeFromSeconds:. See the comment in lookupEntry:... which provides primitive access to this information.
  !

Item was changed:
  Object subclass: #RemoteString
  	instanceVariableNames: 'sourceFileNumber filePositionHi'
+ 	classVariableNames: 'CurrentTextAttStructure CurrentTextAttVersion TextAttributeStructureVersions'
- 	classVariableNames: 'TextAttributeStructureVersions CurrentTextAttVersion CurrentTextAttStructure'
  	poolDictionaries: ''
  	category: 'Files-System'!
  
  !RemoteString commentStamp: '<historical>' prior: 0!
  My instances provide an external file reference to a piece of text.  It may be the sourceCode of a method, or the class comments of a class.
  
  The changes file or file-in file usually has a chunk that is just the source string of a method:
  
  max: aNumber
  	^ self > aNumber ifTrue: [self] ifFalse: [aNumber]!!
  
  I can return either a String or a Text.  Some a chunk is followed by a second chunk (beginning with ]style[) containing style information.  The encoding is like this:
  
  max: aNumber
  	^ self > aNumber ifTrue: [self] ifFalse: [aNumber]!!
  ]style[(14 50 312)f1,f1b,f1LInteger +;i!!
  
  Allowed TextAttributes are TextFontChange, TextEmphasis, TextColor, TextDoIt, TextKern, TextLink, TextURL.  TextFontReference and TextAnchor are not supported.
  
  See PositionableStream nextChunkText and RunArray class scanFrom:.!




More information about the Squeak-dev mailing list