@@ -176,15 +176,16 @@ protected Void call() throws Exception {
176176 }
177177
178178 static File getTsschecker () throws IOException {
179+ if (PlatformUtil .isWindows ()) {
180+ return getTsscheckerWindows ();
181+ }
179182 File executablesFolder = getExecutablesFolder ();
180183 File tsschecker = new File (executablesFolder , "tsschecker" );
181- if (tsschecker .exists ()) {
184+ if (tsschecker .exists () && appPrefs . getBoolean ( "tsschecker last update v2.2.3" , false ) ) {
182185 return tsschecker ;
183186 } else {
184187 InputStream input ;
185- if (PlatformUtil .isWindows ()) {
186- input = Shared .class .getResourceAsStream ("tsschecker_windows.exe" );
187- } else if (PlatformUtil .isMac ()) {
188+ if (PlatformUtil .isMac ()) {
188189 input = Shared .class .getResourceAsStream ("tsschecker_macos" );
189190 } else {
190191 input = Shared .class .getResourceAsStream ("tsschecker_linux" );
@@ -200,8 +201,24 @@ static File getTsschecker() throws IOException {
200201 out .close ();
201202 tsschecker .setReadable (true , false );
202203 tsschecker .setExecutable (true , false );
204+ appPrefs .putBoolean ("tsschecker last update v2.2.3" , true );
205+ return tsschecker ;
206+ }
207+ }
208+
209+ private static File getTsscheckerWindows () throws IOException {
210+ File tsscheckerDir = new File (getExecutablesFolder (), "tsschecker_windows" );
211+ File tsschecker = new File (tsscheckerDir , "tsschecker.exe" );
212+ if (tsschecker .exists () && appPrefs .getBoolean ("tsschecker last update v2.2.3" , false )) {
203213 return tsschecker ;
204214 }
215+ tsscheckerDir .mkdir ();
216+ String jarPath = "/com/airsquared/blobsaver/" + "tsschecker_windows" ;
217+ copyDirFromJar (jarPath , tsscheckerDir .toPath ());
218+ appPrefs .putBoolean ("tsschecker last update v2.2.3" , true );
219+ tsschecker .setReadable (true );
220+ tsschecker .setExecutable (true , false );
221+ return tsschecker ;
205222 }
206223
207224 static File getidevicepair () throws IOException {
@@ -243,6 +260,7 @@ static File getideviceinfo() throws IOException {
243260 }
244261 }
245262
263+ @ SuppressWarnings ("Duplicates" )
246264 private static File getlibimobiledeviceFolder () throws IOException {
247265 File libimobiledeviceFolder ;
248266 if (PlatformUtil .isMac ()) {
@@ -255,64 +273,30 @@ private static File getlibimobiledeviceFolder() throws IOException {
255273 } else {
256274 libimobiledeviceFolder .mkdir ();
257275 if (Shared .class .getResource ("Shared.class" ).toString ().startsWith ("jar:" )) { // if being run from jar
258- try {
259- final Path target = libimobiledeviceFolder .toPath ();
260- URI resource = Shared .class .getResource ("" ).toURI ();
261- if (resource .toString ().endsWith ("blobsaver.exe!/com/airsquared/blobsaver/" )) {
262- resource = URI .create (resource .toString ().replace ("blobsaver.exe!/com/airsquared/blobsaver/" , "blobsaver.jar!/com/airsquared/blobsaver/" ));
263- }
264- java .nio .file .FileSystem fileSystem = FileSystems .newFileSystem (resource , Collections .<String , String >emptyMap ());
265- final Path jarPath ;
266- if (PlatformUtil .isMac ()) {
267- jarPath = fileSystem .getPath ("/com/airsquared/blobsaver/" + "libimobiledevice_mac" );
268- } else {
269- jarPath = fileSystem .getPath ("/com/airsquared/blobsaver/" + "libimobiledevice_windows" );
270- }
271- System .out .println ("jarPath:" + jarPath .toString ());
272- Files .walkFileTree (jarPath , new SimpleFileVisitor <Path >() {
273- private Path currentTarget ;
274-
275- @ Override
276- public FileVisitResult preVisitDirectory (Path dir , BasicFileAttributes attrs ) throws IOException {
277- System .out .println ("in preVisitDirectory, Path:" + dir );
278- currentTarget = target .resolve (jarPath .relativize (dir ).toString ());
279- System .out .println ("after: currentTarget = target.resolve(jarPath.relativize(dir).toString()); " );
280- Files .createDirectories (currentTarget );
281- System .out .println ("after: Files.createDirectories(currentTarget);" );
282- return FileVisitResult .CONTINUE ;
283- }
284-
285- @ Override
286- public FileVisitResult visitFile (Path file , BasicFileAttributes attrs ) throws IOException {
287- System .out .println ("in visitFile, Path:" + file );
288- Path resolveResult = target .resolve (jarPath .relativize (file ).toString ());
289- System .out .println ("after setting resolveResult:" + resolveResult );
290- Files .copy (file , resolveResult , REPLACE_EXISTING );
291- System .out .println ("after: Files.copy(file, target.resolve(jarPath.relativize(file).toString()), REPLACE_EXISTING);" );
292- return FileVisitResult .CONTINUE ;
276+ final String jarPath ;
277+ if (PlatformUtil .isMac ()) {
278+ jarPath = "/com/airsquared/blobsaver/" + "libimobiledevice_mac" ;
279+ } else {
280+ jarPath = "/com/airsquared/blobsaver/" + "libimobiledevice_windows" ;
281+ }
282+ copyDirFromJar (jarPath , libimobiledeviceFolder .toPath ());
283+ try (Stream <Path > paths = Files .walk (new File (System .getProperty ("user.home" ), ".blobsaver_bin" ).toPath ())) {
284+ paths .forEach (path -> {
285+ System .out .println ("in for each loop" );
286+ File file = path .toFile ();
287+ String fileName = file .getName ();
288+ if (!file .isDirectory () && (fileName .contains ("ideviceinfo" ) || fileName .contains ("idevicepair" ) || fileName .contains ("iproxy" ))) {
289+ System .out .println ("setting " + fileName + " to readable and executable" );
290+ file .setReadable (true , false );
291+ file .setExecutable (true , false );
293292 }
294293 });
295- try (Stream <Path > paths = Files .walk (new File (System .getProperty ("user.home" ), ".blobsaver_bin" ).toPath ())) {
296- paths .forEach (path -> {
297- System .out .println ("in for each loop" );
298- File file = path .toFile ();
299- String fileName = file .getName ();
300- if (!file .isDirectory () && (fileName .contains ("ideviceinfo" ) || fileName .contains ("idevicepair" ) || fileName .contains ("iproxy" ))) {
301- System .out .println ("setting " + fileName + " to readable and executable" );
302- file .setReadable (true , false );
303- file .setExecutable (true , false );
304- }
305- });
306- } catch (IOException e ) {
307- e .printStackTrace ();
308- return null ;
309- }
310- System .out .println ("returning from libimobiledevice" );
311- return libimobiledeviceFolder ;
312- } catch (URISyntaxException e ) {
294+ } catch (IOException e ) {
313295 e .printStackTrace ();
314296 return null ;
315297 }
298+ System .out .println ("returning from libimobiledevice" );
299+ return libimobiledeviceFolder ;
316300 } else { // if being run directly from IDEA
317301 System .out .println ("run from idea" );
318302 final Path targetPath = libimobiledeviceFolder .toPath ();
@@ -360,6 +344,44 @@ private static File getExecutablesFolder() throws IOException {
360344 return executablesFolder ;
361345 }
362346
347+ /**
348+ * @param pathToSourceInJar the path to the directory in the jar(ex: "/com/airsquared/blobsaver/libimobiledevice_mac")
349+ * @param target where the directory will be copied to
350+ */
351+ @ SuppressWarnings ("Duplicates" )
352+ private static void copyDirFromJar (String pathToSourceInJar , Path target ) throws IOException {
353+ URI resource = null ;
354+ try {
355+ resource = Shared .class .getResource ("" ).toURI ();
356+ } catch (URISyntaxException e ) {
357+ return ;
358+ }
359+ if (resource .toString ().endsWith ("blobsaver.exe!/com/airsquared/blobsaver/" )) {
360+ resource = URI .create (resource .toString ().replace ("blobsaver.exe!/com/airsquared/blobsaver/" , "blobsaver.jar!/com/airsquared/blobsaver/" ));
361+ }
362+ final java .nio .file .FileSystem fileSystem = FileSystems .newFileSystem (resource , Collections .<String , String >emptyMap ());
363+
364+ final Path jarPath = fileSystem .getPath (pathToSourceInJar );
365+ System .out .println ("jarPath:" + jarPath .toString ());
366+ Files .walkFileTree (jarPath , new SimpleFileVisitor <Path >() {
367+ private Path currentTarget ;
368+
369+ @ Override
370+ public FileVisitResult preVisitDirectory (Path dir , BasicFileAttributes attrs ) throws IOException {
371+ currentTarget = target .resolve (jarPath .relativize (dir ).toString ());
372+ Files .createDirectories (currentTarget );
373+ return FileVisitResult .CONTINUE ;
374+ }
375+
376+ @ Override
377+ public FileVisitResult visitFile (Path file , BasicFileAttributes attrs ) throws IOException {
378+ Path resolveResult = target .resolve (jarPath .relativize (file ).toString ());
379+ Files .copy (file , resolveResult , REPLACE_EXISTING );
380+ return FileVisitResult .CONTINUE ;
381+ }
382+ });
383+ }
384+
363385 static void newGithubIssue () {
364386 if (Desktop .getDesktop ().isSupported (Desktop .Action .BROWSE )) {
365387 try {
0 commit comments