diff options
author | das <das> | 2003-05-13 08:41:26 (GMT) |
---|---|---|
committer | das <das> | 2003-05-13 08:41:26 (GMT) |
commit | b5af58fb48b98becd450e3d7b1e9753d3154d7b9 (patch) | |
tree | e3f550a92be8b1397d2e40c10ee51a7bef9dcb89 /macosx | |
parent | a41f586cbbb2bccd146270743f2479e007b12cb9 (diff) | |
download | tcl-b5af58fb48b98becd450e3d7b1e9753d3154d7b9.zip tcl-b5af58fb48b98becd450e3d7b1e9753d3154d7b9.tar.gz tcl-b5af58fb48b98becd450e3d7b1e9753d3154d7b9.tar.bz2 |
* generic/tcl.decls:
* macosx/tclMacOSXBundle.c: added extended version of the
Tcl_MacOSXOpenBundleResources() API taking an extra version number
argument: Tcl_MacOSXOpenVersionedBundleResources().
This is needed to be able to access bundle resources in versioned
frameworks such as Tcl and Tk, otherwise if multiple versions were
installed, only the latest version's resources could be accessed.
[Bug 736774]
* unix/tclUnixInit.c (Tcl_MacOSXGetLibraryPath): use new versioned
bundle resource API to get tcl runtime library for TCL_VERSION.
[Bug 736774]
* generic/tclPlatDecls.h:
* generic/tclStubInit.c: regen.
* unix/tclUnixPort.h: worked around the issue of realpath() not
being thread-safe on Mac OS X by defining NO_REALPATH for threaded
builds on Mac OS X. [Bug 711232]
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tclMacOSXBundle.c | 82 |
1 files changed, 70 insertions, 12 deletions
diff --git a/macosx/tclMacOSXBundle.c b/macosx/tclMacOSXBundle.c index 7e3dfe7..88def57 100644 --- a/macosx/tclMacOSXBundle.c +++ b/macosx/tclMacOSXBundle.c @@ -83,8 +83,44 @@ Tcl_MacOSXOpenBundleResources( int maxPathLen, char *libraryPath) { + return Tcl_MacOSXOpenVersionedBundleResources(interp, bundleName, + NULL, hasResourceFile, maxPathLen, libraryPath); +} + +/* + *---------------------------------------------------------------------- + * + * Tcl_MacOSXOpenVersionedBundleResources -- + * + * Given the bundle and version name for a shared library (version + * name can be NULL to indicate latest version), this routine sets + * libraryPath to the Resources/Scripts directory in the framework + * package. If hasResourceFile is true, it will also open the main + * resource file for the bundle. + * + * + * Results: + * TCL_OK if the bundle could be opened, and the Scripts folder found. + * TCL_ERROR otherwise. + * + * Side effects: + * libraryVariableName may be set, and the resource file opened. + * + *---------------------------------------------------------------------- + */ + +int +Tcl_MacOSXOpenVersionedBundleResources( + Tcl_Interp *interp, + CONST char *bundleName, + CONST char *bundleVersion, + int hasResourceFile, + int maxPathLen, + char *libraryPath) +{ CFBundleRef bundleRef; CFStringRef bundleNameRef; + CFURLRef libURL; libraryPath[0] = '\0'; @@ -94,11 +130,32 @@ Tcl_MacOSXOpenBundleResources( bundleRef = CFBundleGetBundleWithIdentifier(bundleNameRef); CFRelease(bundleNameRef); - if (bundleRef == 0) { - return TCL_ERROR; - } else { - CFURLRef libURL; + if (bundleVersion && bundleRef) { + /* create bundle from bundleVersion subdirectory of 'Versions' */ + CFBundleRef versionedBundleRef = NULL; + CFURLRef versionedBundleURL = NULL; + CFStringRef bundleVersionRef = CFStringCreateWithCString(NULL, + bundleVersion, kCFStringEncodingUTF8); + CFURLRef bundleURL = CFBundleCopyBundleURL(bundleRef); + if (bundleURL) { + CFURLRef versURL = CFURLCreateCopyAppendingPathComponent(NULL, + bundleURL, CFSTR("Versions"), TRUE); + if (versURL) { + versionedBundleURL = CFURLCreateCopyAppendingPathComponent( + NULL, versURL, bundleVersionRef, TRUE); + CFRelease(versURL); + } + CFRelease(bundleURL); + } + CFRelease(bundleVersionRef); + if (versionedBundleURL) { + versionedBundleRef = CFBundleCreate(NULL, versionedBundleURL); + CFRelease(versionedBundleURL); + } + bundleRef = versionedBundleRef; + } + if (bundleRef) { if (hasResourceFile) { short refNum; refNum = CFBundleOpenBundleResourceMap(bundleRef); @@ -107,20 +164,21 @@ Tcl_MacOSXOpenBundleResources( libURL = CFBundleCopyResourceURL(bundleRef, CFSTR("Scripts"), NULL, NULL); - if (libURL != NULL) { + if (libURL) { /* * FIXME: This is a quick fix, it is probably not right * for internationalization. */ - if (CFURLGetFileSystemRepresentation(libURL, true, - libraryPath, maxPathLen)) { - } + CFURLGetFileSystemRepresentation(libURL, TRUE, + libraryPath, maxPathLen); CFRelease(libURL); - } else { - return TCL_ERROR; } } - - return TCL_OK; + + if (libraryPath[0]) { + return TCL_OK; + } else { + return TCL_ERROR; + } } |