Hi Moses,

The issue is (or was) that for systems which use a volume prefix to the root 
directory, like Windows, the PATH_VOLUME_RELATIVE needs to be handled like 
PATH_ABSOLUTE rather than PATH_RELATIVE, at least as far as File works. In the 
original jacl code and I think 1.2.2 (which is what this snippet came from) the 
PATH_VOLUME_RELATIVE was not handled specifically and would have fallen through 
in the "if" construct to the code for PATH_RELATIVE. 

The bad behavior is generated when getPathType(..) in FileUtil returnes a path 
type of PATH_VOLUME_ABSOLUTE when an initial "/" is detected on a windows 
platform, and getNewFileObj(..) treats this type of path like PATH_RELATIVE and 
generates the wrong path. The simple fix I made go getNewFileObj(..) was to 
treat PATH_VOLUME_ABSOLUTE correctly, i.e., like a PATH_ABSOLUTE since Windows 
defaults to the current volume if you don't specify one.

Thanks,

Erik.

>> >

>> >Not sure what you mean here. Could you provide more info or a patch
>> >and some example code?
>
>
>I looked over the src/jacl/tcl/lang/FileUtil.java and the method
>getNewFileObj. In the 1.0 release of Jacl it was defined like this.
>
>
>static File
>getNewFileObj(
>    Interp interp,                      // Current interpreter.
>    String fileName)                    // File to create object for.
>throws 
>    TclException
>{       
>    File f;
>    fileName = translateFileName(interp, fileName);
>    if (getPathType(fileName) == PATH_ABSOLUTE) {
>        f = new File(fileName);
>    } else {
>        f = new File (interp.getWorkingDir(), fileName);
>    }
>    return f;
>}
>
>
>Your note says that the changes you made were brought over from 1.0
>but I do not see where. Was that a 1.0 alpha release or something?
>If your change fixes a bug under NT, I would like to add it before
>the 1.2.4 release but I need some proof that there is actually a bug.
>Could you privide some test cases that demonstrate this bug in
>the 1.2.3 release? Some test cases and the output they produce both
>before and after the patch would make my life a lot easier.
>
>later
>mo
>
>> Sure, the code from fileUtil is below. I believe this was necessary for 
running 
>> under NT:
>> 
>> 
>> static File
>> getNewFileObj(
>>     Interp interp,                      // Current interpreter.
>>     String fileName)                    // File to create object for.
>> throws
>>     TclException
>> {
>>     final boolean debug = false;
>>     fileName = translateFileName(interp, fileName);^M
>>  */
>>    
>> static File
>> getNewFileObj(
>>     Interp interp,                      // Current interpreter.
>>     String fileName)                    // File to create object for.
>> throws
>>     TclException
>> {
>>     final boolean debug = false;
>>     fileName = translateFileName(interp, fileName);^M
>>     /* ^M
>>      * EP:05/02/1999: Added this to 1.2, copied from 1.0 code.^M
>>      * EP:05/20/1998: Added code to handle PATH_VOLUME_RELATIVE^M
>>      * EP:05/20/1998: This involves changing the path type detection and^M
>>      * EP:05/20/1998: ensuing conditional expression from if to ^M
>>      * EP:05/20/1998: a switch.^M
>>     */^M
>>     int pathType = getPathType(fileName);^M
>>     File f=null;^M
>>     switch (pathType) {^M
>>         case PATH_VOLUME_RELATIVE:^M
>>             f = new File(fileName);^M
>>             break;^M
>>         case PATH_ABSOLUTE:^M
>>             f = new File(fileName);^M
>>             break;^M
>>             // In this case we just get the current working^M
>>             // drive letter.^M
>> //          String path_prepend = 
interp.getWorkingDir().toString().substring(0,
>> 3);^M
>> //          f = new File(path_prepend, fileName);^M
>> //          break;^M
>>         case PATH_RELATIVE:^M
>>             // Here we need to get the current working directory.^M
>>             f = new File(interp.getWorkingDir(), fileName);     ^M
>>             break;^M
>>     }^M
>>     return (f);^M
>> 
>> /*    if (debug) {
>>         System.out.println("File name is \"" + fileName + "\"");
>>     }
>>     if (getPathType(fileName) == PATH_ABSOLUTE) {
>>         if (debug) {
>>             System.out.println("File name is PATH_ABSOLUTE");
>>         }
>>         return new File(fileName);
>>     } else {
>>         if (debug) {
>>             System.out.println("File name is relative");
>>         }
>>         return new File(interp.getWorkingDir(), fileName);
>>     }^M
>>     */
>> }
>> 
>> >
>> >> 1. add support to handle PATH_VOLUME_RELATIVE in FileUtil
>
>

+-------------------------------------------------------------------+
| Erik Pearson                                [EMAIL PROTECTED]  |
|   WWW Engineer                        http://www.adaptations.com  |
|     Adaptations                                     510-527-5437  |
+-------------------------------------------------------------------+



----------------------------------------------------------------
The TclJava mailing list is sponsored by WebNet Technologies.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
A list archive is at: http://www.findmail.com/listsaver/tcldallas/

Reply via email to