Mantis - Squeak
Viewing Issue Advanced Details
1049 Files major always 04-07-05 05:24 01-21-06 09:14
johnmci  
cdegroot  
normal  
closed 3.8  
fixed  
none    
none 3.9  
0001049: oldFileOrNoneNamed: does not work with partial file names and non-default file directory
If you have a FileDirectory instance which is valid and attempt to open an existing file not in the default file directory, it fails however if you use readOnlyFileNamed: that works.

fileDirectoryFoobar oldFileOrNoneNamed: 'text.txt' "fails"
fileDirectoryFoobar readOnlyFileNamed: 'text.txt' "works"
why:

oldFileOrNoneNamed uses FileStream fullName: fileName which resolves to
 FileDirectory default fullNameFor: fileName which gives us the path to the default directory that is work, but if you attempt to test with files in the default directory it works
but
readOnlyFileNamed says
self fullNameFor: localFileName
which then considers the instances of fileDirectory you are using and builds the correct name.
FileDirectory>>oldFileOrNoneNamed: fileName
    "If the file exists, answer a read-only FileStream on it. If it doesn't, answer nil."

    | fullName |
    fullName _ self fullNameFor: fileName.
    (FileStream concreteStream isAFileNamed: fullName)
        ifTrue: [^ FileStream concreteStream readOnlyFileNamed: fullName]
        ifFalse: [^ nil].

Notes
(0002906)
cdegroot   
10-19-05 23:01   
Reproducible in 3.8, not reproducible in 3.9a.

Added test, and sent 3.8 maintainer patch. Committed to inbox as Files-CdG-12
(0003585)
MarcusDenker   
01-21-06 09:14   
fixed