/** * This method gets the IDirectory that represents the root of a virtual file * system. The provided file can either identify a directory, or a zip file. * * @param fs the zip file. * @return the root of the virtual FS. */ public static IDirectory getFSRoot(File fs) { return FileSystemImpl.getFSRoot(fs, null); }
/** * This method gets an ICloseableDirectory that represents the root of a virtual file * system. The provided InputStream should represent a zip file. * * When this {@link ICloseableDirectory} is closed then backing resources will be * cleaned up. * * @param is An input stream to a zip file. * @return the root of the virtual FS. */ public static ICloseableDirectory getFSRoot(InputStream is) { return FileSystemImpl.getFSRoot(is); } }
public IDirectory convertNested() { if (isDirectory()) { return convert(); } else { try { return FileSystemImpl.getFSRoot(file, getParent()); } catch (IORuntimeException e) { return null; } } } }
public static ICloseableDirectory getFSRoot(InputStream is) { File tempFile = null; try { tempFile = File.createTempFile("inputStreamExtract", ".zip"); } catch (IOException e1) { throw new IORuntimeException("IOException in IDirectory.getFSRoot", e1); } FileOutputStream fos = null; try { fos = new FileOutputStream(tempFile); IOUtils.copy(is, fos); } catch (IOException e) { return null; } finally { IOUtils.close(fos); } IDirectory dir = getFSRoot(tempFile, null); if(dir == null) return null; else return new InputStreamClosableDirectory(dir, tempFile); } }