/** * Copy input stream to output stream without closing streams. Flushes output stream when done. * * @param is input stream * @param os output stream * * @throws IOException for any error */ public static void copyStream(InputStream is, OutputStream os) throws IOException { copyStream(is, os, DEFAULT_BUFFER_SIZE); }
static PatchingException rethrowException(final Exception e) { if (e instanceof PatchingException) { return (PatchingException) e; } else { return new PatchingException(e); } }
public Builder addAddOnInfo(String name, TargetInfo info) { addInfo(name, info, false); return this; }
private static File expandContent(File patchFile, final File workDir, final String expandDirName) throws PatchingException { final File patchDir; try { if (!patchFile.isDirectory()) { patchDir = new File(workDir, expandDirName); // Save the content final File cachedContent = new File(patchDir, "content"); IoUtils.copy(patchFile, cachedContent); // Unpack to the work dir ZipUtils.unzip(cachedContent, patchDir); } else { patchDir = patchFile; } } catch (IOException e) { throw new PatchingException("Failed to unzip " + patchFile.getAbsolutePath()); } return patchDir; }
protected static void copyDir(File src, File trg) throws PatchingException { try { IoUtils.copyFile(src, trg); } catch (IOException e) { throw new PatchingException("Failed to copy modification content from " + src.getAbsolutePath() + " to " + trg.getAbsolutePath(), e); } }
private static void assertUpgrade(final PatchType patchType) throws PatchingException { if (!PatchType.CUMULATIVE.equals(patchType)) { throw new PatchingException("Merging one-off patches is not supported at this point."); } }
public static byte[] copy(File source, File target) throws IOException { try (final FileInputStream is = new FileInputStream(source)){ return copy(is, target); } }
private static void installAddOn(File baseDir, String... addOns) throws Exception { for (String addOn : addOns) { IoUtils.mkdir(baseDir, "system", ADD_ONS, addOn); } } }
public static Builder builder() { return new Builder(); }
public VerbosePatchInfo build() { return new VerbosePatchInfo(version, cpId, Collections.unmodifiableList(patchIds), Collections.unmodifiableMap(layers), Collections.unmodifiableMap(addons)); } }
private static File expandContent(File patchFile, final File workDir, final String expandDirName) throws PatchingException { final File patchDir; try { if (!patchFile.isDirectory()) { patchDir = new File(workDir, expandDirName); // Save the content final File cachedContent = new File(patchDir, "content"); IoUtils.copy(patchFile, cachedContent); // Unpack to the work dir ZipUtils.unzip(cachedContent, patchDir); } else { patchDir = patchFile; } } catch (IOException e) { throw new PatchingException("Failed to unzip " + patchFile.getAbsolutePath()); } return patchDir; }
protected static void copyDir(File src, File trg) throws PatchingException { try { IoUtils.copyFile(src, trg); } catch (IOException e) { throw new PatchingException("Failed to copy modification content from " + src.getAbsolutePath() + " to " + trg.getAbsolutePath(), e); } }
static PatchingException rethrowException(final Exception e) { if (e instanceof PatchingException) { return (PatchingException) e; } else { return new PatchingException(e); } }
/** * Copy input stream to output stream without closing streams. Flushes output stream when done. * * @param is input stream * @param os output stream * * @throws IOException for any error */ public static void copyStream(InputStream is, OutputStream os) throws IOException { copyStream(is, os, DEFAULT_BUFFER_SIZE); }
public Builder addLayerInfo(String name, TargetInfo info) { addInfo(name, info, true); return this; }
public static Builder builder() { return new Builder(); }
static PatchingException rethrowException(final Exception e) { if (e instanceof PatchingException) { return (PatchingException) e; } else { return new PatchingException(e); } }
public Builder addAddOnInfo(String name, TargetInfo info) { addInfo(name, info, false); return this; }
static PatchingException rethrowException(final Exception e) { if (e instanceof PatchingException) { return (PatchingException) e; } else { return new PatchingException(e); } }
public Builder addLayerInfo(String name, TargetInfo info) { addInfo(name, info, true); return this; }