private static void unpack(final File nar,final File workingDirectory,final byte[] hash) throws IOException {
  try (JarFile jarFile=new JarFile(nar)){
    Enumeration<JarEntry> jarEntries=jarFile.entries();
    while (jarEntries.hasMoreElements()) {
      JarEntry jarEntry=jarEntries.nextElement();
      String name=jarEntry.getName();
      File f=new File(workingDirectory,name);
      if (jarEntry.isDirectory()) {
        FileUtils.ensureDirectoryExistAndCanAccess(f);
      }
 else {
        makeFile(jarFile.getInputStream(jarEntry),f);
      }
    }
  }
   final File hashFile=new File(workingDirectory,HASH_FILENAME);
  try (final FileOutputStream fos=new FileOutputStream(hashFile)){
    fos.write(hash);
  }
 }

private static void unpack ( final File nar , final File workingDirectory , final byte [ ] hash ) throws IOException { try ( JarFile jarFile = new JarFile ( nar ) ) { Enumeration < JarEntry > jarEntries = jarFile . entries ( ) ; while ( jarEntries . hasMoreElements ( ) ) { JarEntry jarEntry = jarEntries . nextElement ( ) ; String name = jarEntry . getName ( ) ; File f = new File ( workingDirectory , name ) ; if ( jarEntry . isDirectory ( ) ) { FileUtils . ensureDirectoryExistAndCanAccess ( f ) ; } else { makeFile ( jarFile . getInputStream ( jarEntry ) , f ) ; } } } final File hashFile = new File ( workingDirectory , HASH_FILENAME ) ; try ( final FileOutputStream fos = new FileOutputStream ( hashFile ) ) { fos . write ( hash ) ; } }
unpacks the nar to the specified directory . creates a checksum file that used to determine if future expansion is necessary .
