From f493fea1d7844de71bc2f36dc9801d03a2e828ea Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Fri, 30 Jan 2015 10:32:16 +0200 Subject: [PATCH] resolve symlinks before opening file --- .../instantlauncher/menu/MultiLevelMenu.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) 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(); + } } } -- 2.20.1