chrisgr
December 20, 2017, 6:11pm
1
I’m trying to use the JUCE file chooser to see the contents of the iOS user documents directory as follows:
auto ckDocs = File::getSpecialLocation(File::userDocumentsDirectory);
Array<juce::File> results;
ckDocs.findChildFiles(results, juce::File::TypesOfFileToFind::findFilesAndDirectories , true,"*.mid");
std::cout << "files in Docments directory "<< results.size() <<"\n";
FileChooser chooser ("Open Sequence", ckDocs, "*.ckf;*.mid; *.ppf", true);
if (chooser.browseForFileToOpen())
{
File file = chooser.getResult(); //Chooser does not show the user documents folder
if (!file.isDirectory())
{
String fn = file.getFullPathName();
sequenceObject.loadDocument(File(fn));
}
}
My app copies some files to the user documents directory during app startup. I can see they exist using the ckDocs.findChildFiles( …
However when the file chooser opens it only shows “On My iPad”, “iCloud Drive” and “Recently Opened”.
I am specifically asking it to show only the contents of the user documents directory. What is the problem?
You should be able to access contents of your app if you open app’s Info.plist as source and add the following key:
<key>UISupportsDocumentBrowser</key>
<true/>
we should probably add an option for this into Projucer in iOS exporter.
Great! Here I added an option to Projucer, so you don’t have to update the plist manually:
chrisgr
December 21, 2017, 12:22am
5
Great! I’ll update from the dev branch to get it.
I have a related question: The file browser shows midi documents in my iCloud account, and when I click on them they indicate they are downloading to my iPad, but my app reads nothing when it tries to load them. Whereas midi files from my userDocuments directory now do load correctly. Do I need to set something to enable loading documents from the user’s iCloud account?
leehu
December 21, 2017, 7:13am
6
great, didn’t even know this was possible!
leehu
December 21, 2017, 7:26am
7
Hi, when loading from cloud files you need to use the URL results, so in your above example:
if ( !fc.getURLResult().isEmpty() ) {
StringPairArray responseHeaders;
int statusCode = 0;
ScopedPointer<InputStream> p_stream( fc.getURLResult().createInputStream( false, nullptr, nullptr, String(),
10000,&responseHeaders, &statusCode ) );