This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cygpath bug?

"Shankar Unni" <> wrote in message
> BB wrote:
> > Shouldn't GetShortPathName() == 0 always cause the get_short_name()
> > function to fail?
> I would sincerely hope not. I see no reason why cygpath conversion has
> to be tied to the existence of files. We often need to use cygpath to
> convert between formats for files which we are about to create.

I think it should fail if GetShortPathName() returns 0.  A 0 return value
GetShortPathName() failed.  If it returns a 0, it did not modify the
buffer passed to it.  cygpath allocates 1 byte and does a strcpy of the
buffer to that byte.  If that's not a bug, I don't know what is.

> e.g.
>    notepad `cygpath -d "/cygdrive/c/some nonexistent file.txt"`
> will make notepad create that file for me.
Try your example, I don't think it will work.  Maybe you meant to
use the '-w' option.  It will work.

Your example does not work on my machine (XP).  Using the cygpath
-d option causes GetShortPathName() to be called.  It returns 0 and
sets the error to ERROR_PATH_NOT_FOUND.  Using the -w option
is a different story.  It will simply replace the "/cygdrive/c/" with "c:\".
don't think it calls a windows api to do this.

So in effect, the -d option causes a validation of the path and filename.
It cannot be used to convert an invalid directory name to a short filename.

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]