ArchiveFileUtils { public static URI toGZipUri(URI parent) { String parentScheme = parent.getScheme(); String parentSsp = parent.getSchemeSpecificPart(); String gzEntryName = GzipUtils.getUncompressedFilename(FilenameUtils.getName(parent.getSchemeSpecificPart())); final StringBuilder builder = new StringBuilder(parentSsp.length() + ARCHIVE_DELIMITER.length() + gzEntryName.length()); builder.append("gz:").append(parentScheme); String newScheme = builder.toString(); builder.setLength(0); builder.append(parentSsp).append(ARCHIVE_DELIMITER).append(gzEntryName); String newSSP = builder.toString(); try { return new URI(newScheme, newSSP, null); } catch (URISyntaxException e) { throw new RuntimeException(e.getMessage(), e); } } private  ArchiveFileUtils(); static URI toZipUri(URI parent, String zipEntry); static URI toIsoImageUri(URI parent, String imageEntry); static URI toRarUri(URI parent, String rarEntry); static URI toTarUri(URI parent, String tarEntry); static URI toSevenZUri(URI parent, String sevenZipEntry); static URI toFatImageUri(URI parent, String fatEntry); static URI toWebArchiveUri(String archiveType, URI parent, String warcEntry); static Path writeEntryToTemp(final Path tempDir, final ByteBuffer buffer,
                                        final ReadableByteChannel channel); static Path writeFsFileToTemp(final FsDirectoryEntry fsFile, final Path tempDir); static Path writeEntryToTemp(final Path tempDir, final byte[] buffer,
                                        final InputStream in); static URI toGZipUri(URI parent); static URI toBZipUri(URI parent); static URI toReplayUri(URI requestUri); static List<String> getAncestorPaths(String path); static int copyToBuffer(final WindowReader reader, final long position,
                                   final byte[] buffer, final int offset, final int length); static int copyToBuffer(final WindowReader reader, final long position,
                                   final ByteBuffer buffer);  }
@Test public void testBuildGzipUriWithGzExtension() { URI parent = URI.create("file:/C:/anyhost/dir/mygz.tar.gz"); assertEquals("gz:file:/C:/anyhost/dir/mygz.tar.gz!/mygz.tar", ArchiveFileUtils.toGZipUri(parent).toString()); }
@Test public void testBuildGzipUriWithNoGzExtension() { URI parent = URI.create("file:/C:/anyhost/dir/mygz"); assertEquals("gz:file:/C:/anyhost/dir/mygz!/mygz", ArchiveFileUtils.toGZipUri(parent).toString()); }