VirtualDirTgz extends VirtualDir { static String getFilenameFromPath(String path) { int lastSepIndex = path.lastIndexOf("/"); if (lastSepIndex == -1) { lastSepIndex = path.lastIndexOf("\\"); if (lastSepIndex == -1) { return path; } } return path.substring(lastSepIndex + 1, path.length()); } VirtualDirTgz(File tgz); @Override String getBasePath(); @Override InputStream getInputStream(String path); @Override File getFile(String path); @Override String[] list(String path); @Override String[] listAllFiles(); @Override void close(); @Override boolean isCompressed(); @Override boolean isArchive(); @Override void finalize(); @Override File getTempDir();  }
@Test public void testGetFilenameFromPath_Windows() { final String fullPath = "C:\\bla\\blubber\\theFile.txt"; assertEquals("theFile.txt", VirtualDirTgz.getFilenameFromPath(fullPath)); final String relativePath = "bla\\schnuffi\\schnatter.txt"; assertEquals("schnatter.txt", VirtualDirTgz.getFilenameFromPath(relativePath)); }
@Test public void testGetFilenameFromPath_Linux() { final String fullPath = "/bla/blubber/theFile.txt"; assertEquals("theFile.txt", VirtualDirTgz.getFilenameFromPath(fullPath)); final String relativePath = "bla/schnuffi/schnatter.txt"; assertEquals("schnatter.txt", VirtualDirTgz.getFilenameFromPath(relativePath)); }
@Test public void testGetFilenameFromPath_notAPath() { final String file = "theFile.txt"; assertEquals(file, VirtualDirTgz.getFilenameFromPath(file)); }