Open containing folder for files or dirs?

Is there a feature in JUCE "Open containing folder" which just opens the OS default file browser for the file path?

Like:


#if JUCE_LINUX || JUCE_MAC || JUCE_WINDOWS
   /* open the path in the OS native file browser */
   void File::openContainingFolder();
#endif

Cheers

Got it - URL can do this :-)

URL( _file.getFullPathName() ).launchInDefaultBrowser();

Have you tried File::revealToUser() ? Or is that not what you mean?

Yes, that's it what I want!

Thanks

How do you open the folder instead of revealing the folder?

oh, like this, took me a while to understand:

File(userPresetFolder).startAsProcess();

Would have appreciated openFolder() function.
Would also appecreciate existsAsFolder() function.

bool File::existsAsFolder()
{ 
    return exists() && !existsAsFile();
}

void File::openFolder()
{
    if (existsAsFolder())
        startAsProcess();
}

edit: oh, there’s an isDirectory() function.

I agree that having this as an alias is more discoverable and readable

This gets me all the time. File(“somedirectory”).revealToUser() … I imagine most people want to see somedirectory open, not see somedirectory’s parent…

1 Like