FileBrowserComponent navigate to other drives?

I don’t see any way to navigate to other drives using the FileBrowserComponent. I can only go “up” to the root of the current drive. Is there some way to allow the user to change to another drive to look for files/folders?

I see I can type in /Volumes (on my Mac, at least), and go from there, but /Volumes doesn’t show for the user by default. We need to make this as easy as possible for the users, not require them to type in anything if they don’t have to.

I guess the problem is that the Volumes folder is hidden? How do I get that to show? I don’t see anything in recent years that discusses that at all, and the information from back then didn’t help any.

Bump. Just getting back to this issue. I need an easy, obvious way for users to navigate to another volume or drive. How can I do that? (I don’t want to use native dialogs, because child windows in plugins are not preferable.)

I see that for Linux and Windows, holding Command+H toggles whether hidden files are shown, but there does not appear to be a similar way to do anything on the Mac. I need users to be able to select a different volume, if needed, but how?

On Windows, you change the drive using the current path box. I think the same is done on Mac -the box is filled with the return of getDefaultRoots, which does

for (auto& volume : File ("/Volumes").findChildFiles (File::findDirectories, false))
    if (volume.isDirectory() && ! volume.getFileName().startsWithChar ('.'))
        rootPaths.add (volume.getFullPathName());
        rootNames.add (volume.getFileName());

Not sure how that helps me specify that hidden files should be shown. I need the user, using the FileBrowserComponent, to be able to navigate to /Volumes if they want to, not as a default. But when you click the Go Up button, it stops at / without showing /Volumes, because that is hidden.

If I could access the FileBrowserComponent’s fileList member, I could turn off the ignoreHiddenFiles flag, but that’s private and has no accessor, and there is no such flag at the FileBrowserComponent level. Seem to me that should be one of the possible flags you could use when constructing the FileBrowserComponent. No idea why there is simply no way to allow viewing hidden files/folders using this component. I may have to modify that class (which I hate doing).

Simply adding this function resolves the problem:

	void setIgnoresHiddenFiles ( bool shouldIgnoreHiddenFiles )
		if (fileList != nullptr)
			fileList->setIgnoresHiddenFiles( shouldIgnoreHiddenFiles );

It doesn’t, it helps with the original question: how to navigate to other drives.

Ok, but my question was how to use the FileBrowserComponent to do that, not how to do that in general. I don’t want to write my own FileBrowserComponent when one already exists.

Thanks, though.

Oh, I was talking of FileBrowserComponent. I meant that on Windows, as there’s no single root, you change the drive using the current path box, the ComboBox above the FileListComponent. Mac does have a single root, but it makes /Volumes hidden and also implements “artificial” locations for drives. The current path box is filled in resetRecentPaths(), using the return of getRoots(), which by default, unless it’s overriden, calls getDefaultRoots(). The code I quoted is from that function -it loads the subdirectories of /Volumes into the current path box, so they should be there.

Ah, but that’s not what you see if you’ve used setRoot() to set a specific starting point, which is what we have to do. We assume the user wants someplace in their Documents folder, so we start there. If you then use the Up button to navigate to the root (/), then /Volumes does not show in the listing below, because it is hidden. Adding the ability to show hidden files/folders fixes that for me. It does make a bunch of other folders show up that the user doesn’t care about (/usr, for example), but at least it allows showing /Volumes, from which you can then select a different volume. The whole point for me was to prevent the user from having to type in a path if they don’t want to.

Thanks for the help!

1 Like

I added this as a new Feature Request.