Menu

#5 Under Windows, RP1 mangles file names in properties file

RP1_GUI
open-accepted
RP1 GUI (3)
5
2002-03-30
2002-03-28
Andy Gombos
No

If you specify a floor plan on the command line, or in
an ini file, it is read by SimProperties. This also
will probably apply to other paths like the robot
class paths.

You have a Windows path
C:\rossum\floorplans\WhiteRoom.txt

When read into SimProperties, this becomes
C:rossumfloorplansWhiteRomm.txt

When you start the GUI, SimSession tries to find the
floor plan. It can't due to the fact that there are
no path delimiters (it oddly looks just for the /)

An error is logged, but it may never appear before you
are dropped with System.exit(-1).

A temporary fix is to place this line

name = name.replace(File.separator.charAt(0), '/');

into the SimProperties file in the extractString()
method. It should be line 205.

Gary should have a patch up soon, however.

Andy

Discussion

  • G. W. Lucas

    G. W. Lucas - 2002-03-30
    • labels: --> RP1 GUI
    • milestone: --> RP1_GUI
    • assigned_to: nobody --> gwlucas
    • summary: Windows paths corrupt, no error given --> Under Windows, RP1 mangles file names in properties file
    • status: open --> open-accepted
     
  • G. W. Lucas

    G. W. Lucas - 2002-03-30

    Logged In: YES
    user_id=12218

    I'd like to thank Andy Gombos who not only reported this
    problem, but also tracked down the solution. I'm sure
    that everyone who has ever programmed a computer can
    appreciate his comment of the situation:

    Blargh! The problem is inherent in the Java Properties class.

    I've included an explanation of the problem, and a work around
    below.

    Normally, the name of the floor plan file that the users intends
    RP1 to use is specified in a properties file (RP1.ini, etc.)
    as a single name. For example

    floorPlanFileName=trinity2001.txt

    RP1 reads this file from the FloorPlan directory (folder) included
    in the RP1 code distribution. If you wish you may add your
    own file to this folder. Of course, it is not always convenient
    to put a file into the Rossum hierarchy. In that case, you
    can specify a floor plan name using a path name such as:

    c:/MyFolder/MyFloorPlans/trinity2001.txt

    Windows programmers will immediately note that the slashes
    are going in the wrong direction. When he discovered the
    bug, Andy tried something like this:

    c:\MyFolder\MyFloorPlans\trinity2001.txt

    The problem is that the Java Properties class (the Java utility
    that RP1 uses to read its properties files) treats the
    backslash as a special character and removes it from the
    string. Thus, the string above would be rendered as

    c:MyFolderMyFloorPlanstrinity2001.txt

    Why such a weird behavior? It probably reflects the fact that
    Java originated in a Unix community, where the forward slash is
    used to separate files, rather than in a Windows community.
    For now, we have to either write our own version the Java Properties
    class (Andy is thinking about doing just that) or come up
    with a work-around solution.

    Work Arounds:

    1. use the forward slash syntax such as

    c:/MyFolder/MyPlans/trinity2001.txt

    this WILL work under Windows... the Java file-related classes
    map the string appropriately before passing it to the OS.

    2. escape out the backslash as you would if you were
    specifying the string in a C function or Java class:

    c:\\MyFolder\\MyPlans\\trinity2001.txt

    Thanks to Andy's work, we also found that this bug applies
    when you type the floor plan path name on the DOS command line.
    Now, that bug is one that we CAN fix. So I will submit a patch
    in the next week. In the mean time, we recommend that
    if you wish to enter a full path name at the DOS command line,
    you simply quote the string and use the forward slash

    c:\DosPrompt java Server -f "c:/MyFolder/MyPlans/trinity2001.txt"

     

Log in to post a comment.

Auth0 Logo