This patch is against cygpath.cc 1.42.
In 1.43 addressed bug was already fixed, but I believe my fix is a bit better.

Current fix just returns filename, in case filename is for a nonexistent file. I think that internal short to long file name conversion routine could be used in this case, because it deals ok with nonexistent files.
--- cygpath.cc.orig     2006-07-27 13:19:29.765625000 +0300
+++ cygpath.cc  2006-07-27 14:04:20.609375000 +0300
@@ -239,11 +239,26 @@ get_long_name (const char *filename, DWO
     GetLongPathName = get_long_path_name_w32impl;
 
   len = GetLongPathName (filename, buf, MAX_PATH);
-  if (len == 0 && GetLastError () == ERROR_INVALID_PARAMETER)
+  if (len == 0)
     {
-      fprintf (stderr, "%s: cannot create long name of %s\n", prog_name,
-              filename);
-      exit (2);
+      DWORD err = GetLastError ();
+
+      if (err == ERROR_INVALID_PARAMETER)
+       {
+         fprintf (stderr, "%s: cannot create long name of %s\n", prog_name,
+                  filename);
+         exit (2);
+       }
+      else if (err == ERROR_FILE_NOT_FOUND)
+       {
+         len = get_long_path_name_w32impl (filename, buf, MAX_PATH);
+       }
+      else
+       {
+         buf[0] = 0;
+         strncat (buf, filename, MAX_PATH - 1);
+         len = strlen (buf);
+       }
     }
   sbuf = (char *) malloc (len + 1);
   if (!sbuf)
2006-07-03  Ilya Bobir  <[EMAIL PROTECTED]>

        * cygpath.cc (get_long_name): Fallback to get_long_path_name_w32impl.
        Properly null-terminate 'buf'.

Reply via email to