From d97e2c7ba41c66c3d0fd04833e3ea7ca3639541c Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 12 Oct 2012 10:40:21 +0100 Subject: [PATCH] Improvements to file launching on Linux --- modules/juce_core/native/juce_linux_Files.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/juce_core/native/juce_linux_Files.cpp b/modules/juce_core/native/juce_linux_Files.cpp index 7cc17d2684..55b043445e 100644 --- a/modules/juce_core/native/juce_linux_Files.cpp +++ b/modules/juce_core/native/juce_linux_Files.cpp @@ -301,6 +301,15 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, //============================================================================== +static bool isFileExecutable (const String& filename) +{ + juce_statStruct info; + + return juce_stat (filename, info) + && S_ISREG (info.st_mode) + && access (filename.toUTF8(), X_OK) == 0; +} + bool Process::openDocument (const String& fileName, const String& parameters) { String cmdString (fileName.replace (" ", "\\ ",false)); @@ -308,11 +317,13 @@ bool Process::openDocument (const String& fileName, const String& parameters) if (URL::isProbablyAWebsiteURL (fileName) || cmdString.startsWithIgnoreCase ("file:") - || URL::isProbablyAnEmailAddress (fileName)) + || URL::isProbablyAnEmailAddress (fileName) + || File::createFileWithoutCheckingPath (fileName).isDirectory() + || ! isFileExecutable (fileName)) { // create a command that tries to launch a bunch of likely browsers - const char* const browserNames[] = { "xdg-open", "/etc/alternatives/x-www-browser", "firefox", "mozilla", "konqueror", "opera" }; - + const char* const browserNames[] = { "xdg-open", "/etc/alternatives/x-www-browser", "firefox", "mozilla", + "google-chrome", "chromium-browser", "opera", "konqueror" }; StringArray cmdLines; for (int i = 0; i < numElementsInArray (browserNames); ++i)