Page 3 of 3

Re: Left and Right Path

Posted: 18 Jun 2011 12:18
by Stefan
eil wrote: Stefan, can't confirm. just tried

Code: Select all

::run "c:\Progs\Beyond Compare 3\BCompare.exe" "<get path 1>\" "<get path 2>\";
You cheat with adding backslashes manually.

It should work like

Code: Select all

::run "c:\Progs\Beyond Compare 3\BCompare.exe" "<get path 1>" "<get path 2>";
because there is only something weired if one pane is active and it works if the other pane active. (see my post above)

Re: Left and Right Path

Posted: 18 Jun 2011 23:06
by eil
i dot see cheating in using a solution proposed by Don. and it works in all cases that way :)
besides, don't you type all that command manually?-what's wrong adding backslash!.

Re: Left and Right Path

Posted: 19 Jun 2011 09:25
by j_c_hallgren
CodeLobster wrote:id bet they do some research and thus perhaps trying to improve their soft ;)
Just a note: There is no "they" or "their" -- it's just Don (aka admin) that is responsible for creating XY -- we, as fellow forum members, help with testing, suggestions and such but not formally or paid...we just volunteer our time.

Had planned to say that before but never did...I believe other FM's may have a larger staff and thus be a "they", but Don is a one-man-band and is just a "he"...a great "he" though and which makes the speed and amount of development even more amazing!

Re: Left and Right Path

Posted: 20 Jun 2011 12:51
by TheQwerty
To be honest, I think this is as much XYplorer's shortcoming as it is anyone else's.

The issue is not "C:\Folder" vs "C:\Folder\" it is actually "C:\Folder" vs "C:Folder".

"C:" and "C:\" do not necessarily point to the same location according to Microsoft:
If a file name begins with only a disk designator but not the backslash after the colon, it is interpreted as a relative path to the current directory on the drive with the specified letter. Note that the current directory may or may not be the root directory depending on what it was set to during the most recent "change directory" operation on that disk. Examples of this format are as follows:

"C:tmp.txt" refers to a file named "tmp.txt" in the current directory on drive C.
"C:tempdir\tmp.txt" refers to a file in a subdirectory to the current directory on drive C.

EDIT: So this provides an explanation for their behavior I think, but I'm not sure what the solution should be. I'm tempted to say the XY vars should add the trailing slash, at least when they are returning the root of a drive, but I forget why it was done the way it is and am none too thrilled about the potential breaking of many scripts. :?

Re: Left and Right Path

Posted: 20 Jun 2011 13:23
by admin
TheQwerty wrote:To be honest, I think this is as much XYplorer's shortcoming as it is anyone else's.

The issue is not "C:\Folder" vs "C:\Folder\" it is actually "C:\Folder" vs "C:Folder".

"C:" and "C:\" do not necessarily point to the same location according to Microsoft:
If a file name begins with only a disk designator but not the backslash after the colon, it is interpreted as a relative path to the current directory on the drive with the specified letter. Note that the current directory may or may not be the root directory depending on what it was set to during the most recent "change directory" operation on that disk. Examples of this format are as follows:

"C:tmp.txt" refers to a file named "tmp.txt" in the current directory on drive C.
"C:tempdir\tmp.txt" refers to a file in a subdirectory to the current directory on drive C.

EDIT: So this provides an explanation for their behavior I think, but I'm not sure what the solution should be. I'm tempted to say the XY vars should add the trailing slash, at least when they are returning the root of a drive, but I forget why it was done the way it is and am none too thrilled about the potential breaking of many scripts. :?
Something like "C:Folder" is not happening here. What makes you think so?

I decided to return all path variables without trailing slash to make further processing in a script easier. You simply can rely on the fact that whatever is returned has no slash.

Re: Left and Right Path

Posted: 20 Jun 2011 13:59
by TheQwerty
admin wrote:Something like "C:Folder" is not happening here. What makes you think so?
XY returns (and the script passes on) "C:" which isn't an absolute location it is a relative one - pointing to the last working directory on that drive. The fact that the other programs don't treat it as "C:\" is correct behavior because it isn't the same thing.

The fact that the active pane makes a difference makes sense as well if we assume that they treat the arguments in order.

"C:" "C:\Program": With no last working directory on "C", the usage of "C:" gets treated as "C:\".
"C:\Program" "C:": How they check/use "C:\Program" may make it the last working directory on "C" so when they process "C:" next it uses the last working directory which was "C:\Program".


I don't see how this cannot be the culprit or how it is not similar to "C:Folder"… Can you explain why you believe it's not?


Your decision makes sense, unfortunately it relies on the trailing backslash never having any importance which is not the case with the root of the drive. I'd say, in the least, the help file should include some text explaining the subtle differences between "C:" and "C:\".


EDIT: Spelling and minor changes.

Re: Left and Right Path

Posted: 20 Jun 2011 14:14
by admin
TheQwerty wrote:
admin wrote:Something like "C:Folder" is not happening here. What makes you think so?
XY returns (and the script passes on) "C:" which isn't an absolute location it is a relative one - pointing to the last working directory on that drive. The fact that the other programs don't treat it as "C:\" is correct behavior because it isn't the same thing.

The fact that the active pane makes a difference makes sense as well if we assume that they treat the arguments in order.

"C:" "C:\Program": With no last working directory on "C", the usage of "C:" gets treated as "C:\".
"C:\Program" "C:": How they check/use "C:\Program" may make it the last working directory on "C" so when they process "C:" next it uses the last working directory which was "C:\Program".


I don't see how this cannot be the culprit or how it is not similar to "C:Folder"… Can you explain why you belief it's not?


Your decision makes sense, unfortunately it relies on the trailing backslash never having any importance which is not the case with the root of the drive. I'd say, in the least, the help file should probably include some text explaining the subtle differences between "C:" and "C:\".
OK, you are right. I was wrong to assume that the missing trailing slash is the real source of the problem. In fact WinMerge (and assumingly the other apps mentioned here) has no problem to handle paths without slash.

This C: vs C:\ is an overloading in Windows's path syntax (I never heard of before, BTW). And now we are paying the bill. Yep, will mention it in Help. Thanks!

Re: Left and Right Path

Posted: 20 Jun 2011 14:24
by TheQwerty
admin wrote:This C: vs C:\ is an overloading in Windows's path syntax (I never heard of before, BTW).
The only reason I was aware of it is I've accidentally typed commands where I dropped the backslash ("dir C:Folder") and then was very curious why I got results but not at all the ones I was expecting.

Seems like one of their more peculiar design decisions and also one that is frustratingly difficult to research.

EDIT: Also my mistake for referring to it as the last working directory. It's really that drive's current directory. No need to add even further confusion to this. :wink:

Re: Left and Right Path

Posted: 20 Jun 2011 15:33
by PeterH
admin wrote:This C: vs C:\ is an overloading in Windows's path syntax (I never heard of before, BTW). And now we are paying the bill. Yep, will mention it in Help. Thanks!
Some history, if you like?

Imagine the old DOS-days, when you didn't have a filemanager. And you wanted to copy some files between 2 different directories on 2 different drives, with a private utility. You had to repeat again and again (excuse, if there is a small typo somewhere):

Code: Select all

c:\progs\utils\xycopy.exe d:\dir1\dir2\p1.txt e:\foldera\folderb\folderc\
c:\progs\utils\xycopy.exe d:\dir1\dir2\p2.txt e:\foldera\folderb\folderc\
...
To help for this there was something like a "currend directory per drive"! You set:

Code: Select all

cd c:\progs\utils
cd d:\dir1\dir2
cd e:\foldera\folderb\folderc
And then you could abbreviate the former commands to:

Code: Select all

c:xycopy d:p1.txt e:
c:xycopy d:p2.txt e:
...
In situations, where different drives were used, this could be very helpful!

If you defined your program directory in a path variable, and set the current drive, you could further abbreviate:

Code: Select all

cd d:\dir1\dir2
cd e:\foldera\folderb\folderc\
d:
xycopy p1.txt e:
xycopy p2.txt e:
You can test this in a DOS-(=command-)box with
dir /w
dir d: /w
dir d:\ /w
cd d:\x.y.z (path to some existent directory on d:)
dir /w
dir d: /w
Also when setting quite a long path in form d:\a\b\c\d you could wite it complete, and if you made an error, it all was ignored. You had to check, and retype it all again. Or you typed:

Code: Select all

cd d:\a
cd d:b
cd d:c
cd d:d
If you misspelled (after d:b) the d:c, you just said

Code: Select all

dir d: /w
and all possible files and directories in d:\a\b were shown.

That is: the difference between
c:\ (= root on c:) and
c: (= current path on c:)
was *very* handy!

Re: Left and Right Path

Posted: 20 Jun 2011 16:08
by Stefan
So if we are using scripting commands to get the path of "C:\"
and because of...
admin wrote:I decided to return all path variables without trailing slash
... we ended up with getting "C:" instead...

...and the rest what happens we can read above in TheQwerty post.

Thanks TheQwerty and PeterH for digging that out. Makes sense now.