protected void unpackComponents() throws IOException, FileNotFoundException { File applicationPackage = new File(getApplication().getPackageResourcePath()); File componentsDir = new File(sGREDir, "components"); if (componentsDir.lastModified() == applicationPackage.lastModified()) return; componentsDir.mkdir(); componentsDir.setLastModified(applicationPackage.lastModified()); GeckoAppShell.killAnyZombies(); ZipFile zip = new ZipFile(applicationPackage); byte[] buf = new byte[32768]; try { if (unpackFile(zip, buf, null, "removed-files")) removeFiles(); } catch (Exception ex) { // This file may not be there, so just log any errors and move on Log.w(LOG_FILE_NAME, "error removing files", ex); } // copy any .xpi file into an extensions/ directory Enumeration<? extends ZipEntry> zipEntries = zip.entries(); while (zipEntries.hasMoreElements()) { ZipEntry entry = zipEntries.nextElement(); if (entry.getName().startsWith("extensions/") && entry.getName().endsWith(".xpi")) { Log.i("GeckoAppJava", "installing extension : " + entry.getName()); unpackFile(zip, buf, entry, entry.getName()); } } }
/** * Constructor * * @throws IOException */ public JustAnotherPackageManager(Reporter reporter, Platform platform, File homeDir, File binDir) throws IOException { this.platform = platform; this.reporter = reporter; this.homeDir = homeDir; if (!homeDir.exists() && !homeDir.mkdirs()) throw new IllegalArgumentException("Could not create directory " + homeDir); repoDir = IO.getFile(homeDir, "repo"); if (!repoDir.exists() && !repoDir.mkdirs()) throw new IllegalArgumentException("Could not create directory " + repoDir); commandDir = new File(homeDir, COMMANDS); serviceDir = new File(homeDir, SERVICE); commandDir.mkdir(); serviceDir.mkdir(); service = new File(repoDir, SERVICE_JAR_FILE); if (!service.isFile()) init(); this.binDir = binDir; if (!binDir.exists() && !binDir.mkdirs()) throw new IllegalArgumentException("Could not create bin directory " + binDir); }