public static File extractAppFromURL ( URL url ) throws IOException { String fileName = url . toExternalForm ( ) . substring ( url . toExternalForm ( ) . lastIndexOf ( ' ' ) + 1 ) ; File tmpDir = createTmpDir ( "iosd" ) ; log . fine ( "tmpDir: " + tmpDir . getAbsolutePath ( ) ) ; File downloadedFile = new File ( tmpDir , fileName ) ; FileUtils . copyURLToFile ( url , downloadedFile ) ; if ( fileName . endsWith ( ".ipa" ) ) return downloadedFile ; unzip ( downloadedFile , tmpDir ) ; for ( File file : tmpDir . listFiles ( ) ) { if ( file . getName ( ) . endsWith ( ".app" ) ) { return file ; } } throw new WebDriverException ( "cannot extract .app/.ipa from " + url ) ; }
Downloads zip from from url extracts it into tmp dir and returns path to extracted directory