mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
File: Add helper function to locate shared containers on macOS and iOS
File::getContainerForSecurityApplicationGroupIdentifier will return the path to a container which is shared between all apps using the specified app group ID. This might be useful if you need to share resources between a standalone app and an AUv3 plugin, for example.
This commit is contained in:
parent
d738f0274e
commit
b6ab931bcf
3 changed files with 20 additions and 1 deletions
|
|
@ -1074,6 +1074,17 @@ public:
|
|||
void addToDock() const;
|
||||
#endif
|
||||
|
||||
#if JUCE_MAC || JUCE_IOS
|
||||
/** Returns the path to the container shared by all apps with the provided app group ID.
|
||||
|
||||
You *must* pass one of the app group IDs listed in your app's entitlements file.
|
||||
|
||||
On failure, this function may return a non-existent file, so you should check
|
||||
that the path exists and is writable before trying to use it.
|
||||
*/
|
||||
static File getContainerForSecurityApplicationGroupIdentifier (const String& appGroup);
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
/** Comparator for files */
|
||||
struct NaturalFileComparator
|
||||
|
|
|
|||
|
|
@ -506,4 +506,12 @@ void File::addToDock() const
|
|||
}
|
||||
#endif
|
||||
|
||||
File File::getContainerForSecurityApplicationGroupIdentifier (const String& appGroup)
|
||||
{
|
||||
if (auto* url = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier: juceStringToNS (appGroup)])
|
||||
return File (nsStringToJuce ([url path]));
|
||||
|
||||
return File();
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -518,7 +518,7 @@ struct BackgroundDownloadTask : public URL::DownloadTask
|
|||
|
||||
void didFinishDownloadingToURL (NSURL* location)
|
||||
{
|
||||
NSFileManager* fileManager = [[NSFileManager alloc] init];
|
||||
auto* fileManager = [NSFileManager defaultManager];
|
||||
error = ([fileManager moveItemAtURL: location
|
||||
toURL: createNSURLFromFile (targetLocation)
|
||||
error: nil] == NO);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue