Revision: 25278 http://sourceforge.net/p/bibdesk/svn/25278 Author: hofman Date: 2020-12-31 15:57:07 +0000 (Thu, 31 Dec 2020) Log Message: ----------- Avoid deprecated method when targeting newer systems
Modified Paths: -------------- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCacheFile.mm trunk/bibdesk_vendorsrc/amaxwell/FileView/FVQuickLookIcon.m trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCacheFile.mm =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCacheFile.mm 2020-12-31 10:47:22 UTC (rev 25277) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVCacheFile.mm 2020-12-31 15:57:07 UTC (rev 25278) @@ -243,16 +243,13 @@ CFStringRef scheme = CFURLCopyScheme(theURL); CFStringRef identifier = NULL; if (scheme && CFStringCompare(scheme, (CFStringRef)NSURLFileScheme, 0) == kCFCompareEqualTo) { - +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + CFURLCopyResourcePropertyForKey(theURL, kCFURLTypeIdentifierKey, &identifier, NULL); +#else FSRef fileRef; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - if (CFURLGetFSRef(theURL, &fileRef)) { -#pragma clang diagnostic pop - CFTypeRef theUTI; - LSCopyItemAttribute(&fileRef, kLSRolesAll, kLSItemContentType, &theUTI); - if (theUTI) identifier = (CFStringRef)theUTI; - } + if (CFURLGetFSRef(theURL, &fileRef)) + LSCopyItemAttribute(&fileRef, kLSRolesAll, kLSItemContentType, &identifier); +#endif } else if (scheme) { identifier = (CFStringRef)CFRetain(scheme); Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVQuickLookIcon.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVQuickLookIcon.m 2020-12-31 10:47:22 UTC (rev 25277) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVQuickLookIcon.m 2020-12-31 15:57:07 UTC (rev 25278) @@ -52,22 +52,21 @@ + (BOOL)_getBackgroundColor:(CGFloat [])color forURL:(NSURL *)aURL { + BOOL ret = YES; + CFStringRef theUTI; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + if (CFURLCopyResourcePropertyForKey((CFURLRef)aURL, kCFURLTypeIdentifierKey, &theUTI, NULL)) { +#else FSRef fileRef; - BOOL ret = YES; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - if (CFURLGetFSRef((CFURLRef)aURL, &fileRef)) { -#pragma clang diagnostic pop - - CFTypeRef theUTI = NULL; - LSCopyItemAttribute(&fileRef, kLSRolesAll, kLSItemContentType, &theUTI); - + if (CFURLGetFSRef((CFURLRef)aURL, &fileRef) && + noErr == LSCopyItemAttribute(&fileRef, kLSRolesAll, kLSItemContentType, &theUTI)) { +#endif /* No background for movies; the QL icon is always used for .wmv types (see comment in FVIcon for motiviation). Drawing a black background and highlighting it would make the icon look like Finder's Desktop icons, but that's inconsistent with movies that are drawn by FVMovieIcon. */ - if (theUTI && (UTTypeConformsTo(theUTI, kUTTypeMovie) || UTTypeConformsTo(theUTI, kUTTypeAudiovisualContent))) { + if (UTTypeConformsTo(theUTI, kUTTypeMovie) || UTTypeConformsTo(theUTI, kUTTypeAudiovisualContent)) { ret = NO; } else { @@ -77,7 +76,7 @@ color[2] = 1; color[3] = 1; } - if (theUTI) CFRelease(theUTI); + CFRelease(theUTI); } return ret; } Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m =================================================================== --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m 2020-12-31 10:47:22 UTC (rev 25277) +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m 2020-12-31 15:57:07 UTC (rev 25278) @@ -360,6 +360,39 @@ #pragma mark - +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +bool FVCanMapFileAtURL(NSURL *fileURL) +{ + NSCParameterAssert([fileURL isFileURL]); + + CFBooleanRef flag; + bool rv = false; + if (CFURLCopyResourcePropertyForKey((CFURLRef)fileURL, kCFURLVolumeIsInternalKey, &flag, NULL)) { + rv = CFBooleanGetValue(flag); + CFRelease(flag); + } + CFTypeID volumeID; + if (rv == false && CFURLCopyResourcePropertyForKey((CFURLRef)fileURL, kCFURLVolumeIdentifierKey, &volumeID, NULL)) { + CFTypeID otherVolumeID; + if (CFURLCopyResourcePropertyForKey((CFURLRef)[NSURL fileURLWithPath:NSOpenStepRootDirectory()], kCFURLVolumeIdentifierKey, &otherVolumeID, NULL)) { + rv = CFEqual(volumeID, otherVolumeID); + CFRelease(otherVolumeID); + } + if (rv == false) { + CFURLRef bundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + if (bundleURL && CFURLCopyResourcePropertyForKey(bundleURL, kCFURLVolumeIdentifierKey, &otherVolumeID, NULL)) { + rv = CFEqual(volumeID, otherVolumeID); + CFRelease(otherVolumeID); + } + if (bundleURL) CFRelease(bundleURL); + } + CFRelease(volumeID); + } + return rv; +} + +#else + static OSStatus __FVGetVolumeRefNumForURL(NSURL *fileURL, FSVolumeRefNum *volume) { NSCParameterAssert([fileURL isFileURL]); @@ -366,18 +399,12 @@ OSStatus err = noErr; FSRef fileRef; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (nil == fileURL || FALSE == CFURLGetFSRef((CFURLRef)fileURL, &fileRef)) -#pragma clang diagnostic push err = fnfErr; FSCatalogInfo catInfo; if (noErr == err) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" err = FSGetCatalogInfo(&fileRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL); -#pragma clang diagnostic push if (noErr == err && volume) *volume = catInfo.volume; return err; @@ -438,6 +465,7 @@ else return false; } +#endif #if !defined(MAC_OS_X_VERSION_10_9) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit