malxau/yori

move improperly ignores trailing \ or /

jstarks opened this issue · 2 comments

I typically write trailing slashes on directory names that are targets of move/copy to ensure that the target directory exists. To my surprise, yori's move ignores this:

C:\Users\jostarks\tmp>touch foo
C:\Users\jostarks\tmp>move foo bar\
C:\Users\jostarks\tmp>dir bar

 Directory of C:\Users\jostarks\tmp

03/14/2021  03:22 PM                  0 bar
           1 File(s)                  0 bytes
           0 Dir(s)      22,598,160,384 bytes free

copy gets this right:

C:\Users\jostarks\tmp>touch foo
C:\Users\jostarks\tmp>copy foo bar\
CopyFile failed: C:\Users\jostarks\tmp\foo to C:\Users\jostarks\tmp\bar\: The filename, directory name, or volume label syntax is incorrect.

I looked into this and it seems much less surprising.

Yori is using the paths specified in that error report to the API. I didn't debug into kernel, but moving C:\Users\jostarks\tmp\foo to C:\Users\jostarks\tmp\bar\ at the NtSetInformationFile level will create a file.

CMD's behavior is a little different because it detects the trailing slash and appends the file name after it, so the API gets C:\Users\jostarks\tmp\bar\foo , which gets a failure.

I changed this behavior in commit ae3889c .

However, because the API doesn't behave in the way you're expecting, I have to ask: which other commands should have this behavior?

This should be fixed in 1.50, released today. Please let me know if there are further related issues.