getSpecialLocation() returns empty strings on Mac


Hi all,

I’m using File::getSpecialLocation(File::currentApplicationFile) to get the plugin folder and with Windows it works as documented, but on a Mac (MacIntel if it matters), the AU version only returns empty strings.
The same happens with other SpecialLocationTypes…

Juce gets correctly initialised and all the rest seems to work correctly.

What’s wrong then?


Good point - in an app, when it starts up, juce_setCurrentExecutableFileName() gets called to set the exe, but I don’t know a good way of doing the same thing in an AU…


Here’s what I did (almost all plain Carbon code) in an old AU plugin (still working today) that I developed when I still was using my own cross platform framework: CPL.

I’m sure you’ll be able to get the sense and maybe to add that to your great toolkit.

(cpl::MString objects were my string classes, cpl::MApplicationImpl was the class doing the implementation for a bridged Application class abstracted from the OSs).

cpl::MString MApplicationImpl::GetAppOSFullPath()
cpl::MString strPath;

CFStringRef cfstrBundleIdentifier = CFStringCreateWithCString(NULL,m_pAbstraction->GetBundleIdentifier().c_str(),kCFStringEncodingUTF8);
if (!cfstrBundleIdentifier)
	// We have to define a bundle identifier into the Info.plist file, or the system is not able to reach the path of this bundle
	return strPath;

CFBundleRef cfbThisBundle = CFBundleGetBundleWithIdentifier(cfstrBundleIdentifier);

if (!cfbThisBundle)
	// The identifier typed-in in the source code (at application initialization, presumably) does not
	// correspond to the Info.plist bundle identifier
	return strPath;

CFURLRef cfuExecutable = CFBundleCopyExecutableURL(cfbThisBundle);
if (!cfuExecutable)
	// Cannot get executable's URL (we have to define the executable name into the Info.plist file)
	return strPath;

CFStringRef cfstrFullPath = CFURLCopyFileSystemPath(cfuExecutable, kCFURLPOSIXPathStyle);
if (!cfstrFullPath)
	// Something wrong while allocating CFString? ...
	return strPath;

CFIndex nSize = CFStringGetLength(cfstrFullPath) + 1;
char* szPath = new char[nSize];

CFStringGetCString(cfstrFullPath, szPath, nSize, CFStringGetSystemEncoding());

strPath = cpl::MString(szPath);

delete [] szPath;

return strPath;



Ah - ok, thanks! I’ll take a look through that and see what I can come up with…