CrLfFileStream on MacOSX

Rik Smoody Rik2 at smoo.com
Sat Feb 17 01:26:49 UTC 2007


I stumbled upon (probably) the same issue.
Evidence, from an old image, but running it on newer VM:

Performed by Squeak 3.8.15beta1U.app, on a Mac OS X 10.3.9:
FileDirectory allSubclasses collect: [:class | class->class 
primPathNameDelimiter ]
a Set(MacHFSPlusFileDirectory->$/ AcornFileDirectory->$/ 
UnixFileDirectory->$/ MacFileDirectory->$/ DosFileDirectory->$/)

The answer from Squeak 3.8.9beta8.app, on the same Mac
a Set(MacHFSPlusFileDirectory->$: AcornFileDirectory->$: 
UnixFileDirectory->$: MacFileDirectory->$: DosFileDirectory->$:)

The old-version answer is somewhat more compatible with the Mac.

For example, when running one old utility image, I got this message:
/Tomato:Users:Rik:Pictures does not exist
the problem apparently caused by that leading $/
as changing that manually back to a $: reveals the expected existence 
of the file.

On 2007 Feb 15, at 3:41 PM, Andrew P. Black wrote:

>
> On 13 Feb 2007, at 17:17, Andrew P. Black wrote:
>
>> I have noticed that CrLfFileStream class >> 
>> guessDefaultLineEndConvention does not work on my MacOSX system
>>
>> DirectoryClass (a class variable, defined in class FileDirectory) is  
>> UnixFileDirectory on my system, which seems reasonable — but  that 
>> class hard-codes the path separator to be /, which 
>> guessDefaultLineEndConvention uses to guess that LF is the right line 
>> ending convention.
>>
>> This explains, perhaps, why LF characters are increasingly polluting 
>> the sources and changes files.
>
> I deathly silence followed this post, which lead me to suspect that I 
> had said something very foolish.  However, I haven't been able to 
> figure out what.    Perhaps if I continue to prattle on, someone will 
> tell me.
>
> The value of LineEndDefault seems to matter only when creating a new 
> file; when reading a file, or over-writing a file, the existing 
> content of the file governs whether the cr message writes LF or CR, 
> and what line endings cause next to answer CR.
>
> However, when it matters, it matters.  I can't be the only MacOSX user 
> to notice that writing a text file fills it with LFs!
>
> The fix seems to be simple: check to see if we are running on Darwin.
>
> CrLfFileStream class >> guessDefaultLineEndConvention
> 	"Lets try to guess the line end convention from what we know about the
> 	path name delimiter from FileDirectory and the identity of the OS."
> 	FileDirectory pathNameDelimiter = $:
> 		ifTrue: [^ self defaultToCR].
> 	FileDirectory pathNameDelimiter = $/
> 		ifTrue: [((SmalltalkImage current getSystemAttribute: 1002) 
> beginsWith: 'darwin')
> 				ifTrue: [^ self defaultToCR]
> 				ifFalse: [^ self defaultToLF]].
> 	FileDirectory pathNameDelimiter = $\
> 		ifTrue: [^ self defaultToCRLF].
> 	"in case we don't know"
> 	^ self defaultToCR
>
>
> Shall I submit this as a bugfix?
>
> 	Andrew
>
>
>
>
Rik Smoody       Rik3 at smoo.com
  smOOdynamics  - Object-Orientation is the middle of our name
	Portland, OR  503-249-8300




More information about the Squeak-dev mailing list