"Shankar Unni" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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 means GetShortPathName() failed. If it returns a 0, it did not modify the destination buffer passed to it. cygpath allocates 1 byte and does a strcpy of the uninitialized 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:\". I 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: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/