diff options
author | das <das> | 2003-05-13 08:40:29 (GMT) |
---|---|---|
committer | das <das> | 2003-05-13 08:40:29 (GMT) |
commit | abbcb0c269fc4339825f49ec99f9799d03f0340e (patch) | |
tree | 7d20211b679af52f135bd538105f8017afb4d882 /macosx | |
parent | d9e8d364d0d3c76e689634b79e78346209c437d1 (diff) | |
download | tcl-abbcb0c269fc4339825f49ec99f9799d03f0340e.zip tcl-abbcb0c269fc4339825f49ec99f9799d03f0340e.tar.gz tcl-abbcb0c269fc4339825f49ec99f9799d03f0340e.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; + } } |