Opened 11 years ago

Closed 11 years ago

#2731 closed defect (fixed)

classDirectory() does not conform to uses in commercial libraries

Reported by: Henrik Tidefelt Owned by: somebody
Priority: high Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: Cc: Martin Sjölund

Description

The example in #1184 uses classDirectory() in the following way that is also seen in commercial libraries:

classDirectory() + ".."

In other words, it is assumed that the resulting string has a trailing directory separator.

Some commercial libraries also use classDirectory() under the assumption that the resulting string is an absolute directory name.

Currently, classDirectory() conforms to neither of these assumptions.

If this non-standard feature is provided to support commercial libraries, and unless there are examples out there that rely on relative directory names or the absence of the trailing separator, these incompatibilities should be fixed.

Please comment with any examples out there that rely on the current behavior.

Change History (7)

comment:1 by Martin Sjölund, 11 years ago

Cc: Martin Sjölund added

comment:2 by Martin Sjölund, 11 years ago

How do you make it not return an absolute path? Parser.mo forces all loaded files to have an absolute path.

comment:3 by Martin Sjölund, 11 years ago

r21269 appends a "/" or "\" depending on platform, so the given pattern works.

comment:4 by Henrik Tidefelt, 11 years ago

Good to have the trailing separator, but doesn't classDirectory() always use the "/", just like loadResource and other Modelica functions? I did some testing under Windows which seems to confirm this.

My apologies regarding the absoluteness of paths; it works as expected in OpenModelica.

comment:5 by Martin Sjölund, 11 years ago

So you want it to always use "/" regardless of platform? I can change that easily.

comment:6 by Henrik Tidefelt, 11 years ago

Seams reasonable to me. I suppose you would get odd-looking results like c:/blah/blah\ on Windows otherwise.

Regarding which separator to use, I'm just guessing that using only "/" rather than only native separators is going to work better when the result of classDirectory() is used in combination with other functions.

comment:7 by Martin Sjölund, 11 years ago

Resolution: fixed
Status: newclosed

Fixed in r21273.

Note: See TracTickets for help on using tickets.