OSDN Git Service

* shortcut.c (check_shortcut): Close input file handle before returning. pre-posix-scan
authorcgf <cgf>
Sun, 22 Apr 2001 16:19:26 +0000 (16:19 +0000)
committercgf <cgf>
Sun, 22 Apr 2001 16:19:26 +0000 (16:19 +0000)
* path.cc (check_sysfile): Ditto.
(symlink_info::check): Rely on opened file handle being closed by symlink
checking routines.  Set ext_tacked_on when .lnk is detected.

winsup/cygwin/ChangeLog
winsup/cygwin/path.cc
winsup/cygwin/shortcut.c

index 63ab22c..56e1b5d 100644 (file)
@@ -1,3 +1,11 @@
+Sun Apr 22 12:17:57 2001  Christopher Faylor <cgf@cygnus.com>
+
+       * shortcut.c (check_shortcut): Close input file handle before
+       returning.
+       * path.cc (check_sysfile): Ditto.
+       (symlink_info::check): Rely on opened file handle being closed by
+       symlink checking routines.  Set ext_tacked_on when .lnk is detected.
+
 Sat Apr 21 19:26:05 2001  Christopher Faylor <cgf@cygnus.com>
 
        * thread.cc (MTinterface::Init): Remove accidentally checked in code.
index 137d913..c218a16 100644 (file)
@@ -2504,6 +2504,8 @@ check_sysfile (const char *path, DWORD fileattr, HANDLE h,
       }
   syscall_printf ("%d = symlink.check_sysfile (%s, %s) (%p)",
                  res, path, contents, *pflags);
+
+  CloseHandle (h);
   return res;
 }
 
@@ -2698,29 +2700,29 @@ symlink_info::check (const char *path, const suffix_info *suffixes,
       res = -1;
       if (h == INVALID_HANDLE_VALUE)
        goto file_not_symlink;
-      else if (sym_check == 1
-               && !(res = check_shortcut (suffix.path, fileattr, h,
-                                         contents, &error, &pflags)))
+
+      switch (sym_check)
        {
-         CloseHandle (h);
-         /* If searching for `foo' and then finding a `foo.lnk' which is
-            no shortcut, return the same as if file not found. */
-         if (suffix.lnk_match ())
+       case 1:
+         res = check_shortcut (suffix.path, fileattr, h, contents, &error, &pflags);
+         if (res)
            {
-             fileattr = (DWORD)-1;
-             continue;         /* in case we're going to tack *another* .lnk on this filename. */
+             ext_tacked_on = 1;
+             break;
            }
-         goto file_not_symlink;
-       }
-      else if (sym_check == 2 &&
-              !(res = check_sysfile (suffix.path, fileattr, h,
-                                     contents, &error, &pflags)))
-       {
-         CloseHandle (h);
-         goto file_not_symlink;
+         /* If searching for `foo' and then finding a `foo.lnk' which is
+            no shortcut, return the same as if file not found. */
+         if (!suffix.lnk_match ())
+           goto file_not_symlink;
+
+         fileattr = (DWORD) -1;
+         continue;             /* in case we're going to tack *another* .lnk on this filename. */
+       case 2:
+         res = check_sysfile (suffix.path, fileattr, h, contents, &error, &pflags);
+         if (!res)
+           goto file_not_symlink;
+         break;
        }
-
-      CloseHandle (h);
       break;
     }
   goto out;
index b7ca869..b47cec5 100644 (file)
@@ -98,7 +98,7 @@ check_shortcut (const char *path, DWORD fileattr, HANDLE h,
     goto close_it;
   /* Read the files header information. This is used to check for a
      Cygwin or U/WIN shortcut or later to check for executable files. */
-  if (! ReadFile (h, file_header, SHORTCUT_HDR_SIZE, &got, 0))
+  if (!ReadFile (h, file_header, SHORTCUT_HDR_SIZE, &got, 0))
     {
       *error = EIO;
       goto close_it;
@@ -160,8 +160,7 @@ close_it:
     psl->lpVtbl->Release(psl);
   /* Uninitialize COM library. */
   CoUninitialize ();
+  CloseHandle (h);
 
   return res;
 }
-
-