[Jslib] Uninstall UI

Pete Collins pete at mozdev.org
Sun Dec 7 10:39:39 EST 2003


> But since it calls getZip, I'm still not sure if that will suffice.
> Guess I'll have a dig into nsJar.cpp as soon as I have time... :)


Yep, works lke a charm. I just tested on Windows and the latest jslib 
uninstall code removed the jar file.

Patch I checked in is below.

Works real nice!


--pete

-- 
Pete Collins
www.mozdev.org
www.mozdevgroup.com

-------------- next part --------------
Index: libraries/install/uninstall.js
===================================================================
RCS file: /cvs/jslib/libraries/install/uninstall.js,v
retrieving revision 1.20
diff -u -w -s -r1.20 uninstall.js
--- libraries/install/uninstall.js	6 Dec 2003 20:01:18 -0000	1.20
+++ libraries/install/uninstall.js	7 Dec 2003 15:40:13 -0000
@@ -249,6 +249,20 @@
       // non-empty directories should not be deleted.
       try {
         var file = this.filesToDelete[t];
+        var path = file.path;
+        var ext = path.substring(path.lastIndexOf(".")+1, path.length);
+        // close the jar filehandle so we can unlock it and delete it on 
+        // OS's like Windows that like to lock their open files
+        if (ext == "jar") {
+          var IOService = C.classes["@mozilla.org/network/io-service;1"]
+                          .getService(C.interfaces.nsIIOService);
+          var handler = IOService.getProtocolHandler("jar");
+          if (handler instanceof C.interfaces.nsIJARProtocolHandler) {
+            var zrc = handler.JARCache;
+            var nsIZipReader = zrc.getZip(file);
+            nsIZipReader.close();
+          }
+        }
         if (file.exists()) file.remove(false);
       }
       catch (ex){ jslibDebug(ex); }


More information about the Jslib mailing list