From: Svjatoslav Agejenko Date: Fri, 30 Jan 2015 08:32:16 +0000 (+0200) Subject: resolve symlinks before opening file X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=f493fea1d7844de71bc2f36dc9801d03a2e828ea;p=instantlauncher.git resolve symlinks before opening file --- diff --git a/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java b/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java index f66f952..017872f 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java @@ -117,15 +117,24 @@ public class MultiLevelMenu implements MenuListener { if (chosenFile.canExecute()) { executeCommand(chosenFile.getAbsolutePath()); } else { - final boolean fileOpened = FileAssociationManager.openFile(chosenFile); - if (fileOpened) { - InstantLauncher.exitProgram(); + boolean fileOpened; + try { + fileOpened = FileAssociationManager.openFile(chosenFile.getCanonicalFile()); + if (fileOpened) { + InstantLauncher.exitProgram(); + } + } catch (IOException e) { + e.printStackTrace(); } } } if (chosenFile.isDirectory()) { - executeCommand("nautilus", "-w", chosenFile.getAbsolutePath()); + try { + executeCommand("nautilus", "-w", chosenFile.getCanonicalFile().getAbsolutePath()); + } catch (IOException e) { + e.printStackTrace(); + } } } @@ -144,7 +153,12 @@ public class MultiLevelMenu implements MenuListener { if (chosenFile.isFile()) { chosenFile.setExecutable(!chosenFile.canExecute()); } else { - executeCommand("gnome-terminal", "--working-directory=" + chosenFile.getAbsolutePath()); + try { + executeCommand("gnome-terminal", "--working-directory=" + + chosenFile.getCanonicalFile().getAbsolutePath()); + } catch (IOException e) { + e.printStackTrace(); + } } } @@ -163,7 +177,11 @@ public class MultiLevelMenu implements MenuListener { @Override public void menuItemSelectedAlternative2(Menu menu, File chosenFile) { if (chosenFile.isFile()) { - executeCommand("emacs", chosenFile.getAbsolutePath()); + try { + executeCommand("emacs", chosenFile.getCanonicalFile().getAbsolutePath()); + } catch (IOException e) { + e.printStackTrace(); + } } }