@Test @EnabledOnOs(OS.MAC) public void testDesktopLinkExists() throws Exception { FileUtils.recursiveDelete(new File(userHome), new File("/tmp")); assertTrue(new File(userHome).exists() == false); final String appName = "MyFirstApp"; final String appNameWithSuffix = appName + AppFactory.APP_EXTENSION; assertTrue(AppFactory.desktopLinkExists(appName) == false); final Path desktop = Paths.get(JavaSystemProperties.getUserHome(), "Desktop"); Files.createDirectories(desktop); assertTrue(Files.isDirectory(desktop)); final Path link = desktop.resolve(appNameWithSuffix); { assertTrue(Files.exists(link) == false); Files.createFile(link); assertTrue(Files.exists(link) == true); assertTrue(AppFactory.desktopLinkExists(appName) == false); Files.delete(link); } { assertTrue(Files.exists(link) == false); Files.createDirectories(link); assertTrue(Files.isDirectory(link) == true); assertTrue(AppFactory.desktopLinkExists(appName) == false); Files.delete(link); } final Path appRoot = AppFactory.createAppWithoutMenuEntry(appName, appNameWithSuffix, IcnsFactorySample.class.getResource("icon.png").getFile()).toPath(); { assertTrue(Files.exists(link) == false); Files.createSymbolicLink(link, appRoot.resolve(AppFactory.CONTENTS_FOLDER_NAME)); assertTrue(Files.isSymbolicLink(link) == true); assertTrue(AppFactory.desktopLinkExists(appName) == false); Files.delete(link); } { assertTrue(Files.exists(link) == false); Files.createSymbolicLink(link, appRoot); assertTrue(Files.isSymbolicLink(link) == true); assertTrue(AppFactory.desktopLinkExists(appName) == true); Files.delete(link); } }
public final static boolean desktopLinkExists(final String appname) { Assert.requireNonBlank(appname, "appname"); final Path cache = getApplicationRootInCache(appname); if (Files.isDirectory(cache)) { final Path link = getDesktopLink(appname); if (Files.isSymbolicLink(link)) { try { final Path linkRealPath = link.toRealPath(); return cache.toRealPath().equals(linkRealPath); } catch (final Exception e) { LOG.debug("Coluld not verify desktop link [" + link + "]", e); } } } return false; }
AppFactory { public final static boolean desktopLinkExists(final String appname) { Assert.requireNonBlank(appname, "appname"); final Path cache = getApplicationRootInCache(appname); if (Files.isDirectory(cache)) { final Path link = getDesktopLink(appname); if (Files.isSymbolicLink(link)) { try { final Path linkRealPath = link.toRealPath(); return cache.toRealPath().equals(linkRealPath); } catch (final Exception e) { LOG.debug("Coluld not verify desktop link [" + link + "]", e); } } } return false; } }
AppFactory { public final static boolean desktopLinkExists(final String appname) { Assert.requireNonBlank(appname, "appname"); final Path cache = getApplicationRootInCache(appname); if (Files.isDirectory(cache)) { final Path link = getDesktopLink(appname); if (Files.isSymbolicLink(link)) { try { final Path linkRealPath = link.toRealPath(); return cache.toRealPath().equals(linkRealPath); } catch (final Exception e) { LOG.debug("Coluld not verify desktop link [" + link + "]", e); } } } return false; }  }
AppFactory { public final static boolean desktopLinkExists(final String appname) { Assert.requireNonBlank(appname, "appname"); final Path cache = getApplicationRootInCache(appname); if (Files.isDirectory(cache)) { final Path link = getDesktopLink(appname); if (Files.isSymbolicLink(link)) { try { final Path linkRealPath = link.toRealPath(); return cache.toRealPath().equals(linkRealPath); } catch (final Exception e) { LOG.debug("Coluld not verify desktop link [" + link + "]", e); } } } return false; }  static boolean exists(final String name); static void createApp(final String name, final String script, final String... iconPaths); final static boolean desktopLinkExists(final String appname); final static void createDesktopLink(final String appname, final String script, final String... iconPaths); }
AppFactory { public final static boolean desktopLinkExists(final String appname) { Assert.requireNonBlank(appname, "appname"); final Path cache = getApplicationRootInCache(appname); if (Files.isDirectory(cache)) { final Path link = getDesktopLink(appname); if (Files.isSymbolicLink(link)) { try { final Path linkRealPath = link.toRealPath(); return cache.toRealPath().equals(linkRealPath); } catch (final Exception e) { LOG.debug("Coluld not verify desktop link [" + link + "]", e); } } } return false; }  static boolean exists(final String name); static void createApp(final String name, final String script, final String... iconPaths); final static boolean desktopLinkExists(final String appname); final static void createDesktopLink(final String appname, final String script, final String... iconPaths); final static String CONTENTS_FOLDER_NAME; final static String APP_EXTENSION; }