Corinna Vinschen wrote:
On Jul 29 12:29, Ilya wrote:
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.

If you could regenerate your patch so that it's against current CVS, I
will take it, since its size will then be below the "trivial fix" rule.
Please see http://cygwin.com/contrib.html, "Before you get started",
second paragraph.


Thanks,
Corinna
No problem :)

--- cygpath.cc.orig     2006-07-30 16:15:30.390625000 +0300
+++ cygpath.cc  2006-07-30 16:15:05.953125000 +0300
@@ -241,15 +241,24 @@ get_long_name (const char *filename, DWO
   len = GetLongPathName (filename, buf, MAX_PATH);
   if (len == 0)
     {
-      if (GetLastError () == ERROR_INVALID_PARAMETER)
+      DWORD err = GetLastError ();
+
+      if (err == ERROR_INVALID_PARAMETER)
        {
          fprintf (stderr, "%s: cannot create long name of %s\n", prog_name,
-                  filename);
+                  filename);
          exit (2);
        }
-      buf[0] = '\0';
-      strncat (buf, filename, MAX_PATH - 1);
-      len = strlen (buf);
+      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