OSDN Git Service

* fhandler_disk_file.cc (fhandler_disk_file::readdir): Reorganize to avoid
authorcgf <cgf>
Thu, 27 Nov 2003 23:27:23 +0000 (23:27 +0000)
committercgf <cgf>
Thu, 27 Nov 2003 23:27:23 +0000 (23:27 +0000)
inappropriate .lnk extensions with munged filenames under managed mode.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_disk_file.cc

index ad11c50..992d56f 100644 (file)
@@ -1,3 +1,9 @@
+2003-11-27  Christopher Faylor  <cgf@redhat.com>
+
+       * fhandler_disk_file.cc (fhandler_disk_file::readdir): Reorganize to
+       avoid inappropriate .lnk extensions with munged filenames under managed
+       mode.
+
 2003-11-26  Corinna Vinschen  <corinna@vinschen.de>
 
        * sec_helper.cc (set_process_privilege): Rename restore_priv to
index e19c196..faebc45 100644 (file)
@@ -704,29 +704,29 @@ fhandler_disk_file::readdir (DIR *dir)
       return res;
     }
 
-  /* We get here if `buf' contains valid data.  */
-  if (get_encoded ())
-    (void) fnunmunge (dir->__d_dirent->d_name, buf.cFileName);
-  else
-    strcpy (dir->__d_dirent->d_name, buf.cFileName);
-
   /* Check for Windows shortcut. If it's a Cygwin or U/WIN
      symlink, drop the .lnk suffix. */
   if (buf.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
     {
-      char *c = dir->__d_dirent->d_name;
+      char *c = buf.cFileName;
       int len = strlen (c);
       if (strcasematch (c + len - 4, ".lnk"))
        {
          char fbuf[CYG_MAX_PATH + 1];
          strcpy (fbuf, dir->__d_dirname);
-         strcpy (fbuf + strlen (fbuf) - 1, dir->__d_dirent->d_name);
+         strcpy (fbuf + strlen (fbuf) - 1, c);
          path_conv fpath (fbuf, PC_SYM_NOFOLLOW);
          if (fpath.issymlink () || fpath.isspecial ())
            c[len - 4] = '\0';
        }
     }
 
+  /* We get here if `buf' contains valid data.  */
+  if (get_encoded ())
+    (void) fnunmunge (dir->__d_dirent->d_name, buf.cFileName);
+  else
+    strcpy (dir->__d_dirent->d_name, buf.cFileName);
+
   dir->__d_position++;
   res = dir->__d_dirent;
   syscall_printf ("%p = readdir (%p) (%s)",