@Test public void testArchiveDetection() { String parentPath = TestFiles.archive_detection.getPath(); String[] candidateNames = { "real-zip.zip", "fake-zip-is-file.zip", "fake-zip-is-directory.zip", "nested-test.zip/real-zip.zip", "nested-test.zip/fake-zip-is-file.zip", "nested-test.zip/fake-zip-is-directory.zip" }; boolean[] expectedOutputs = { true, false, false, true, false, false }; assertTrue(candidateNames.length == expectedOutputs.length); for (int i = 0; i < candidateNames.length; i++) { String fullPath = parentPath + "/" + candidateNames[i]; TFile file = new TFile(fullPath); assertTrue(file.exists()); boolean actualOutput = UtilModel.isZipArchive(file); assertEquals(expectedOutputs[i], actualOutput); } }
@VisibleForPackageGroup public static boolean isZipArchive(@NotNull TFile file) { if (file.isFile()) return false; if (! file.isEntry()) return new java.io.File(file.getPath()).isFile(); return new TFile( Util.getParentFile(file), file.getName(), TArchiveDetector.NULL ).isFile(); }
UtilModel { @VisibleForPackageGroup public static boolean isZipArchive(@NotNull TFile file) { if (file.isFile()) return false; if (! file.isEntry()) return new java.io.File(file.getPath()).isFile(); return new TFile( Util.getParentFile(file), file.getName(), TArchiveDetector.NULL ).isFile(); } }
UtilModel { @VisibleForPackageGroup public static boolean isZipArchive(@NotNull TFile file) { if (file.isFile()) return false; if (! file.isEntry()) return new java.io.File(file.getPath()).isFile(); return new TFile( Util.getParentFile(file), file.getName(), TArchiveDetector.NULL ).isFile(); } private  UtilModel(); }
UtilModel { @VisibleForPackageGroup public static boolean isZipArchive(@NotNull TFile file) { if (file.isFile()) return false; if (! file.isEntry()) return new java.io.File(file.getPath()).isFile(); return new TFile( Util.getParentFile(file), file.getName(), TArchiveDetector.NULL ).isFile(); } private  UtilModel(); @NotNull static String getRelativePathIfPossible(@NotNull File file); @NotNull @VisibleForPackageGroup static String getRelativePath(	@NotNull String srcPath,
											@NotNull String dstPath); @NotNull @VisibleForPackageGroup static String getRelativePath(	@NotNull File srcFile,
											@NotNull File dstFile); @VisibleForPackageGroup static void assertDocCount(	Directory luceneDir,
										int expectedCount); @VisibleForPackageGroup static void assertResultCount(	Directory luceneDir,
											String query,
											int expectedCount); @VisibleForPackageGroup static boolean isZipArchive(@NotNull TFile file); @Nullable @VisibleForPackageGroup static File maybeUnpackZipEntry(	@NotNull IndexingConfig config,
											@NotNull File file); static boolean isUnmodifiedArchive(	@NotNull Folder<?, ?> folder,
												@Nullable Long newLastModified); static final void fail(	@NotNull IndexingReporter reporter,
									@NotNull ErrorType type,
									@NotNull TreeNode treeNode,
									@Nullable Throwable cause); }
UtilModel { @VisibleForPackageGroup public static boolean isZipArchive(@NotNull TFile file) { if (file.isFile()) return false; if (! file.isEntry()) return new java.io.File(file.getPath()).isFile(); return new TFile( Util.getParentFile(file), file.getName(), TArchiveDetector.NULL ).isFile(); } private  UtilModel(); @NotNull static String getRelativePathIfPossible(@NotNull File file); @NotNull @VisibleForPackageGroup static String getRelativePath(	@NotNull String srcPath,
											@NotNull String dstPath); @NotNull @VisibleForPackageGroup static String getRelativePath(	@NotNull File srcFile,
											@NotNull File dstFile); @VisibleForPackageGroup static void assertDocCount(	Directory luceneDir,
										int expectedCount); @VisibleForPackageGroup static void assertResultCount(	Directory luceneDir,
											String query,
											int expectedCount); @VisibleForPackageGroup static boolean isZipArchive(@NotNull TFile file); @Nullable @VisibleForPackageGroup static File maybeUnpackZipEntry(	@NotNull IndexingConfig config,
											@NotNull File file); static boolean isUnmodifiedArchive(	@NotNull Folder<?, ?> folder,
												@Nullable Long newLastModified); static final void fail(	@NotNull IndexingReporter reporter,
									@NotNull ErrorType type,
									@NotNull TreeNode treeNode,
									@Nullable Throwable cause);  }