The Inbox: Files-ul.93.mcz

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

The Inbox: Files-ul.93.mcz

commits-2
A new version of Files was added to project The Inbox:
http://source.squeak.org/inbox/Files-ul.93.mcz

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

Name: Files-ul.93
Author: ul
Time: 26 December 2010, 3:15:49.208 am
UUID: 8a24a548-5339-3449-a85f-3878c10a6209
Ancestors: Files-cmm.92

- use MultiByteFileStream for stdio files instead of CrLfFileStream
- added a comment and a warning to CrLfFileStream about the deprecation

=============== Diff against Files-cmm.92 ===============

Item was changed:
  StandardFileStream subclass: #CrLfFileStream
  instanceVariableNames: 'lineEndConvention'
  classVariableNames: 'Cr CrLf Lf LineEndDefault LineEndStrings LookAheadCount'
  poolDictionaries: ''
  category: 'Files-Kernel'!
 
+ !CrLfFileStream commentStamp: 'ul 12/26/2010 03:13' prior: 0!
+ This class is now obsolete, use MultiByteFileStream instead.
+
- !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:
  ----- Method: CrLfFileStream class>>new (in category 'class initialization') -----
  new
 
+ self deprecated: 'This class is now obsolete, use MultiByteFileStream instead.'.
  ^ (MultiByteFileStream new) wantsLineEndConversion: true; yourself.
 
  !

Item was removed:
- ----- Method: CrLfFileStream class>>newForStdio (in category 'instance creation') -----
- newForStdio
- "Circumvent CrLfFileStream new's retuning an instance of MultiBteFileStream"
- ^super new!

Item was removed:
- ----- Method: CrLfFileStream>>openOnHandle:name:forWrite: (in category 'open/close') -----
- openOnHandle: aFileID name: streamName forWrite: writeMode
- "Initialize the file with the given handle. If writeMode is true then
- allow writing, otherwise put the file in read-only mode."
- super openOnHandle: aFileID name: streamName forWrite: writeMode.
- lineEndConvention := LineEndDefault!

Item was removed:
- ----- Method: StandardFileStream class>>newForStdio (in category 'private-file creation') -----
- newForStdio
- "Circumvent CrLfFileStream new's returning an instance of MultiBteFileStream"
- ^self new!

Item was changed:
  ----- Method: StandardFileStream class>>standardIOStreamNamed:forWrite: (in category 'private-file creation') -----
  standardIOStreamNamed: moniker forWrite: forWrite
 
  | index |
  index := #(stdin stdout stderr) identityIndexOf: moniker.
  ^((stdioFiles ifNil: [ stdioFiles := Array new: 3 ]) at: index)
  ifNil: [
  stdioFiles
  at: index
  put: (
  (StdioHandles at: index)
  ifNil: [ ^self error: moniker, ' is unavailable' ]
+ ifNotNil: [ :handle |
+ self new
- ifNotNil: [ :handle|
- self newForStdio
  openOnHandle: handle
  name: moniker
  forWrite: forWrite ]) ]!