FileChooser::getResults returns path with inconsistent backslash count


#1

Hi,

I found that FileChooser::getResults returns different path string between single and multiple files selected:

Call FileChooser::browseForMultipleFilesToOpen to open dialog. Select single file, the return content of getResults look as below:

  • C:\Windows

But when select multiple files, the content of getResults look as below:

  • C:\\Windows
  • C:\\ProgramsData

The backslash count is not the same. Although both are valid file path, is this expected behavior?


#2

Hi sam,

I’ve tried to reproduce this but I get a consistent path string with a single backslash from getResults for both single and multiple files selected. Could you post some code to demonstrate this?

Ed


#3

Hi @ed95,

I did more tests and look likes this problem only happen when choosing file from removable storage. Below is the system information and code snippets (using JUCE Unit Test).

  • Windows 10
  • JUCE 4.3.0
  • F: is removable disk (SD Card)
  • idrotate.exe is a file on F:

When choose only idrotate.exe, the test will pass. If choose idrotate.exe along with other file, the test will fail.

class FileChooserTest : public UnitTest
{
public:
	FileChooserTest()
		: UnitTest("FileChooserTest")
	{}

	void runTest() override
	{
		beginTest("FileChooserTest");
		FileChooser fc("Test",
					   File("F:\\"),
					   "*.exe;*.bat");
		fc.browseForMultipleFilesToOpen();
		Array<juce::File> picked = fc.getResults();
		DBG(picked[0].getFullPathName());
		expect(picked[0].getFullPathName().equalsIgnoreCase("F:\\idrotate.exe"));
	}
};

#4

@sam yep, thanks for the code I can reproduce this now. Looks like it happens when you select multiple files located on the root of a drive. I’ll take a look at it.

Ed


#5

Should be fixed on develop now.

Ed


#6

Yes. I confirmed the issue is fixed in develop branch. Thank you!