mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-01 03:10:06 +00:00
Improvements to file launching on Linux
This commit is contained in:
parent
521067b615
commit
d97e2c7ba4
1 changed files with 14 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue