[BUG][FIX] Cannot open files in a Mac volume's root

John M McIntosh johnmci at smalltalkconsulting.com
Mon Mar 22 14:23:36 UTC 2004


Right and I'll resubmit the patch that might fix it, someone might want 
to test (again) and then someone might want  to stick it in the update 
stream.
Plus for completeness I'll attach the sunit test stephane ducasse & 
Karl Ramberg wrote to test it.


On Mar 22, 2004, at 2:24 AM, Bert Freudenberg wrote:

> The culprit seems to be "MacFileDirectory class>>isAbsolute:" which 
> answers false if no colon is found inside the file name - which is the 
> case for a volume name.
>
> To reproduce: Open a file list, select a volume (scroll all the way up 
> in the directory pane), and select a file in that volume (not in a 
> subdirectory). You may have to buy a Mac first and install Squeak.
>
> - Bert -
>
>
>
>


Change Set:		MacRootPathNameFix-JMM
Date:			18 June 2003
Author:			johnmci at smalltalkconsulting.com

Attempting to open a file 'foobar.txt' on Volume 'fum' will fail, the 
path is fum:foobar.txt. This change set alters MacFileDirectory 
class>>isAbsolute: to consider that fum is a root thus fum:foobat.txt 
is a absolute pathname"!


!MacFileDirectory class methodsFor: 'class initialization' stamp: 'JMM 
6/18/2003 23:33'!
isAbsolute: fileName
	"Return true if the given fileName is absolute. The rules are:

If a path begins with a colon, it is relative.
Otherwise,
   If it contains a colon anywhere, it is absolute and the first 
component is the volume name.
   Otherwise,
     It is absolute because it is a volume name."

	fileName first = $: ifTrue: [^false].
	(fileName includes: $:) ifTrue: [^true].
	(fileName size > 0) ifTrue: [^true].
	^false! !

---------------------------------

'From Squeak3.7alpha of ''11 September 2003'' [latest update: #5497] on 
27 October 2003 at 8:49:26 pm'!
"Change Set:		MacFileDirecto
Date:			27 October 2003
Author:			stephane ducasse & Karl Ramberg

Two tests that cover the bugs of the isAbsolute: on mac"!

TestCase subclass: #MacFileDirectoryTest
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'SUnit'!

!MacFileDirectoryTest methodsFor: 'test' stamp: 'sd 10/27/2003 18:05'!
testMacFileDirectory
	"(self run: #testMacFileDirectory)"
	
	"This fails before the the fix if the Squeak directory is on the root
	directory like: 'HardDisk:Squeak'
	But should work both before and after the fix of John if there is 
several
	directories in the hieracry: HardDisk:User:Squeak"
	"If somebody can find a way to make the test failed all the time when 
the fix is not
	present we should replace it"

	self assert: (FileDirectory default fullName) = (FileDirectory default 
fullNameFor: (FileDirectory default fullName))! !

!MacFileDirectoryTest methodsFor: 'test' stamp: 'sd 10/27/2003 18:18'!
testMacFileFullPathFor
	"(self run: #testMacFileFullPathFor)"
	

	self assert: (MacFileDirectory isAbsolute: (FileDirectory default 
fullPathFor:  (FileDirectory default fullName))).
	self assert: (MacFileDirectory isAbsolute: (FileDirectory on: 'Data') 
pathName).

! !

!MacFileDirectoryTest methodsFor: 'test' stamp: 'sd 10/27/2003 17:43'!
testMacIsAbsolute
	"(self selector: #testMacIsAbsolute) run"
	
	
	self assert: (MacFileDirectory isAbsolute: 'Volumes').
	self assert: (MacFileDirectory isAbsolute: 'Volumes:Data:Stef').
	self deny: (MacFileDirectory isAbsolute: ':Desktop:test.st')! !

!MacFileDirectoryTest methodsFor: 'test' stamp: 'sd 10/27/2003 18:02'!
testMakeAbsolute

	self assert: (MacFileDirectory isAbsolute: (MacFileDirectory 
makeAbsolute: 'Data')).
	self assert: (MacFileDirectory isAbsolute: (MacFileDirectory 
makeAbsolute: ':Data')).
! !





More information about the Squeak-dev mailing list