-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling relative paths. Confusion with deconstructPathname #264
Comments
K maybe scratch some of what I said above. Now I think what I want is for |
Hi, Chris. This stuff is very difficult to think about clearly. As best I can tell That is the kind of crap that deconstructPathname() is built to sort out. I am not sure I understand exactly what you are trying to do, but I wonder if a simple extension to deconstructPathname() might do what you want. Currently a file beginning with "." is processed by replacing the "." with the absolute cwd. It sounds like maybe you would like to use that same syntax, but where "." refers to a particular directory of your choosing, rather than the cwd, and ".." would mean one up from your directory, while processing of root-relative path names would remain unchanged. That could easily be done by adding a new Pathname method |
That would work, mostly, but it still seems to me that a path like |
By the definition used in deconstructPathname(), that is an absolute path because it is cwd relative (and cwd is an absolute path). You should definitely not change that behavior, because then you can't use deconstructPathname() to determine whether you need to apply a search path. I should have used some different terms than relative/absolute here; what's meant is "search path should apply"/"search path should not apply". I still think that |
I believe that is a poorly-worded attempt to say that while processing a path like In the code, a given path name that actually does start with |
@carmichaelong, I thought of one more ugly Windows case I don't think we discussed:
What should be the absolute pathname in that case? My thought is that since only one drive was explicitly mentioned, that drive should be used. So the absolute path name would be:
But in that case it would be wrong to pre-process the specifiedWorkingDirectory (swd) to turn it into an absolute path first! So maybe the rule is:
|
Why does Windows exist! |
To summarize a conversation Chris, Carmichael, and I just had:
Thanks, guys! |
Thanks for summarizing. |
The above case of ambiguous drive letters makes sense. What about the following case?
Assume that the current drive is X:. Do we return:
Case 1 would imply that pathName is a full path (this is unambiguous in not-Windows). Case 2 implies that having a drive letter dominates in Windows. |
Yuck! Good catch, Carmichael. One way to think about that is how we would want it to behave in the OpenSim case we've been discussing. That would mean we are processing a file like My first thought is that we should interpret the path as an absolute path name but on the swd drive. So I would propose (weakly) that the answer is a case 3: |
Chris, I believe PR #307 has addressed this issue which you opened. Please close if you agree. |
🎆 |
I am working on opensim-org/opensim-core#118. @sherm1 , in this issue you claim that
Based on the Pathname API, this does not seem possible. So I have been trying to alter Pathname::getAbsolutePathname to suit my needs.
My objective is to take a path
pathname
that is relative an arbitrary pathbase
, and express it as either (1) a relative path that is relative to my cwd, or (2) an absolute path.I made the necessary changes to
getAbsolutePathname
so that it could use abase
that is not the cwd. However, I misunderstood whatdeconstructPathname
does. The documentation contains the confusing statement:How can an absolute path be relative to something else? I fed this method a path like
../../myfile
and was told that this is an absolute path. I learned thatdeconstructPathname
is trying to do more than it advertises: it converts relative paths to absolute paths if you pass it "keywords" such as../
,./
,@
. So from this perspective, indeed,./
specifies an absolute path. I feel this is improper;getAbsolutePathname
should do that; I simply wanted to deconstruct the path as given.I believe my current method of trying to do (1) or (2) cannot be done simply by modifying
getAbsolutePathname
.@sherm1 does Pathname, as is, provide the functionality I seek? If not, I would like to alter
deconstructPathname
so that it strictly decomposes a given path, and does not try to create an absolute path based on keywords. I'm happy to take other suggestions as well.The text was updated successfully, but these errors were encountered: