texlive[44058] Master/tlpkg/TeXLive/TLWinGoo.pm: Windows only new

commits+siepo at tug.org commits+siepo at tug.org
Wed Apr 26 13:27:52 CEST 2017


Revision: 44058
          http://tug.org/svn/texlive?view=revision&revision=44058
Author:   siepo
Date:     2017-04-26 13:27:52 +0200 (Wed, 26 Apr 2017)
Log Message:
-----------
Windows only new filetypes: take other read failures into account

Modified Paths:
--------------
    trunk/Master/tlpkg/TeXLive/TLWinGoo.pm

Modified: trunk/Master/tlpkg/TeXLive/TLWinGoo.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLWinGoo.pm	2017-04-26 09:08:27 UTC (rev 44057)
+++ trunk/Master/tlpkg/TeXLive/TLWinGoo.pm	2017-04-26 11:27:52 UTC (rev 44058)
@@ -798,20 +798,50 @@
   return 1;
 }
 
+#############################
+# not overwriting an existing file association
+
+# read error is sometimes access_denied,
+# therefore we ONLY decide that a value does not exist if
+# an attempt to read it errors out with file_not_found.
+
+# windows error codes
+my $file_not_found = 2; # ERROR_FILE_NOT_FOUND
+my $reg_ok = 0; # ERROR_SUCCESS
+
+# inaccessible value (note. actual filetypes shound not have spaces)
+my $reg_unknown = 'not accessible';
+
 # Effective default value of any key under Classes.
 # admin: HKLM; user: HKCU or otherwise HKLM
-# Reject if there is no corresponding key under classes
 sub current_filetype {
   my $extension = shift;
   my $filetype;
+  my $regerror;
+
   if ($is_admin) {
-    $filetype = lm_root()->{"Software/Classes/$extension//"}; # REG_SZ
+    $regerror = $reg_ok;
+    $filetype = lm_root()->{"Software/Classes/$extension//"} # REG_SZ
+      or $regerror = Win32API::Registry::regLastError();
+    if ($regerror != $reg_ok and $regerror != $file_not_found) {
+      return $reg_unknown;
+    }
   } else {
     # Mysterious failures on w7_64 => merge HKLM/HKCU info explicitly
     # rather than checking HKCR
-    $filetype = cu_root()->{"Software/Classes/$extension//"};
+    $regerror = $reg_ok;
+    $filetype = cu_root()->{"Software/Classes/$extension//"} or
+      $regerror = Win32API::Registry::regLastError();
+    if ($regerror != $reg_ok and $regerror != $file_not_found) {
+      return $reg_unknown;
+    }
     if (!defined($filetype) or ($filetype eq "")) {
-      $filetype = lm_root()->{"Software/Classes/$extension//"}
+      $regerror = $reg_ok;
+      $filetype = lm_root()->{"Software/Classes/$extension//"} or
+        $regerror = Win32API::Registry::regLastError();
+      if ($regerror != $reg_ok and $regerror != $file_not_found) {
+        return $reg_unknown;
+      }
     };
   }
   $filetype = "" unless defined($filetype);



More information about the tex-live-commits mailing list