FSFilesystemTest>>testReferenceTo fails on Windows

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

FSFilesystemTest>>testReferenceTo fails on Windows

Ben Coman
I have loaded ConfigurationOfFilesystem v2.0.3 into Pharo-1.3-13315 on
Windows 7.

All tests are green except
    FSFilesystemTest>>testReferenceTo
which hard codes the unix root folder...
    self assert: (filesystem referenceTo: '/') isRoot.

However, guessing at the semantics of isRoot, simply changing this to...
    self assert: (filesystem referenceTo: 'C:\') isRoot.
is not sufficient since...
    FSAbsolutePath>>isRoot
        ^ self size = 0
has size = 1.

Looking into this further, it appears that the test for absolute path is
incorrect in FSWindowStore>>pathFromString: aString.  It is not the
drive letter and colon that make it an absolute path, but whether the
third character is a slash as well.  Consider this sequence from a new
command window ...
    C:\>    mkdir C:\TestC1
    C:\>    cd TestC1
    C:\TestC1>   E:
    E:\>   mkdir C:TestC2
    E:\>   C:
    C:\testC1>   cd \testC1\testC2
    C:\testC1\testC2>

Definitively... [1] "Section 'Fully Qualified vs. Relative Paths' >>  If
a file name begins with only a disk designator but not the backslash
after the colon, it is interpreted as a relative path to the current
directory on the drive with the specified letter. "

[1]
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx

Without knowing the design philosophy or architecture of FS I'll just
wildly speculate on on implementation.... by FSDiskStore having an
instance variable "volume." For Unix this would remain empty.  For
Windows this would be 'C:' or 'D:' (without the slash).  Then once this
volume is stripped from the front of the path, the super method could be
used, and (^ self size = 0) in  FSAbsolutePath>>isRoot  would be true.
         For example...

FSWindowStore>>pathFromString: aString
    | class |
    class :=  ((aString at: 1) isLetter and: [(aString at: 2) = $:])
        ifTrue:
        [    volume := (aString at: 1) asString , ":" .
             ^ super pathFromString: (aString copyFrom: 3 to: (aString
size)).
        ]
       ^ super pathFromString: aString.

FSStore>>pathFromString
    peek = $/
would also need to be replaced by
    peek = self delimiter.

OR... perhaps...
FSDiskStore>>pathFromString: aString
    self volumeFromString: aString.
    super pathFromString: ( aString copyFrom: (self volume size) + 1 to:
(aString size) ).

FSDiskStore>>volume
    volume ifNil: [ volume := '' ].

FSDiskStore>>volumeFromString
    ^self.

FSWindowStore>>volumeFromString: aString
       ((aString at: 1) isLetter and: [(aString at: 2) = $:])
        ifTrue:
        [    volume := (aString at: 1) asString , ":" .
        ]
       "also handle UNC volumes here"

Also are UNC paths under consideration?  Here the volume
'\\server\share' might be extracted from the front of the path and
isRoot would be True at this location.  From [1] ...  "The "\\?\" prefix
can also be used with paths constructed according to the universal
naming convention (UNC). To specify such a path using UNC, use the
"\\?\UNC\" prefix. For example, "\\?\UNC\server\share", where "server"
is the name of the computer and "share" is the name of the shared
folder. These _ prefixes are not used as part of the path itself. _ "

Anyway, that is as far as I can take it.  Obviously lots of implications
I haven't considered.  Hope this helps.

cheers, -ben

Reply | Threaded
Open this post in threaded view
|

Re: FSFilesystemTest>>testReferenceTo fails on Windows

Ben Coman

>
>    C:\TestC1>   E:    E:\>   mkdir C:TestC2
>  
note this should be two lines

C:\TestC1>   E:  
E:\>   mkdir C:TestC2


Reply | Threaded
Open this post in threaded view
|

Re: FSFilesystemTest>>testReferenceTo fails on Windows

Ben Coman
Ben Coman wrote:

>
>>
>>    C:\TestC1>   E:    E:\>   mkdir C:TestC2
>>  
> note this should be two lines
>
> C:\TestC1>   E:   E:\>   mkdir C:TestC2
>
>
>
damn try again. sorry for the noise.

C:\TestC1>   E:  

<newline>

E:\>   mkdir C:TestC2