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 -
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@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')). ! !
Am 22.03.2004 um 15:23 schrieb John M McIntosh:
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
I don't think that'll work. Consider this:
FileDirectory default --> MacHFSPlusFileDirectory on 'Macintosh HD:Users:bert:Squeak'
FileDirectory default directoryNamed: 'Macintosh HD:bla' --> MacHFSPlusFileDirectory on 'Macintosh HD:bla'
So far, so fine. But:
FileDirectory default directoryNamed: 'Macintosh HD' --> MacHFSPlusFileDirectory on 'Macintosh HD:Users:bert:Squeak:Macintosh HD'
instead of
--> MacHFSPlusFileDirectory on 'Macintosh HD'
as your #isAbsolute: would imply.
Unfortunately, this idiom is used everywhere to look into subdirectories of the image directory.
!MacFileDirectory class methodsFor: 'class initialization' stamp: 'JMM 6/18/2003 23:33'! isAbsolute: fileName "[...]" fileName first = $: ifTrue: [^false]. (fileName includes: $:) ifTrue: [^true]. (fileName size > 0) ifTrue: [^true]. ^false! !
TerseMan sayz:
isAbsolute: fileName ^fileName first ~= $:
... which is absolutely equivalent to the code above ;-)
- Bert -
Actually this usage doesn't call MacFileDirectory>>isAbsolute: So the logic doesn't get invoked.
Soooo I altered a few things and now have a change set so that if you do
FileDirectory default directoryNamed: 'Network'
they you get a directory on the Network volume.
This is based on deciding if the path is empty, and the local name is the same a volume name, then we say it's the volume name, versus saying it's a directory in the default directory.
So is it "Macintosh HD:Network" here or is it "Network"
Comments please.
I've not tested on other platforms, but lets see if we can clean up this lingering issue
On Mar 22, 2004, at 8:51 AM, Bert Freudenberg wrote:
FileDirectory default directoryNamed: 'Macintosh HD'
-- ======================================================================== === John M. McIntosh johnmci@smalltalkconsulting.com 1-800-477-2659 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ======================================================================== ===
Am 23.03.2004 um 03:32 schrieb John M McIntosh:
Actually this usage doesn't call MacFileDirectory>>isAbsolute: So the logic doesn't get invoked.
Soooo I altered a few things and now have a change set so that if you do
FileDirectory default directoryNamed: 'Network'
they you get a directory on the Network volume.
Great, let's get this in!
However ...
This is based on deciding if the path is empty, and the local name is the same a volume name, then we say it's the volume name, versus saying it's a directory in the default directory.
Which means I cannot access a subdirectory in my image directory that has the same name as a mounted volume ...
So is it "Macintosh HD:Network" here or is it "Network"
Comments please.
They're both equivalent, AFAICT.
I've not tested on other platforms, but lets see if we can clean up this lingering issue
IMHO this will not become clean until we switch to Unix file names. Indeed, what's the status on the GUM VM (*)?
For example: If I mount the "shared documents" folder from two Windows machines, I get *two* volumes named "SHAREDDOCS". Really! The Finder can distinguish between both, but in Squeak, I can only access the contents of the first one, even if I click on the second. It seems the Finder internally uses Unix file names and only presents the HFS filenames in its UI. We probably should do the same (and hide all the .files, for example).
- Bert -
(*) Grand Unified MacOSX VM
Problem was caused by the handling of absolute and relative names. The volume name of a file which resides on a root volume does not look like an absolute bath when taken by itself. The attached changeset fixes it, but a more elegant solution would be preferred. Duplicating the relatively large FileDirectory>>fullNameFor: method into MacFileDirectory does not look too nice.
John said that this fix was better than his so let us approve this one.
squeak-dev@lists.squeakfoundation.org