Revision: 26821 http://sourceforge.net/p/bibdesk/svn/26821 Author: hofman Date: 2021-09-07 23:01:05 +0000 (Tue, 07 Sep 2021) Log Message: ----------- Combine converting path URL to reference URL from different sources
Modified Paths: -------------- trunk/bibdesk/BDSKLinkedFile.m Modified: trunk/bibdesk/BDSKLinkedFile.m =================================================================== --- trunk/bibdesk/BDSKLinkedFile.m 2021-09-07 22:52:40 UTC (rev 26820) +++ trunk/bibdesk/BDSKLinkedFile.m 2021-09-07 23:01:05 UTC (rev 26821) @@ -546,44 +546,39 @@ if (wantsBookmark) { // using bookmark and NSURL if (fileRef == nil) { - NSURL *refURL = nil; - + NSURL *aURL = nil; + if (fileURL) { - refURL = (NSURL *)CFURLCreateFileReferenceURL(kCFAllocatorDefault, (CFURLRef)fileURL, NULL); - shouldUpdate = basePath != nil && refURL != nil; + aURL = [fileURL retain]; + shouldUpdate = basePath != nil && aURL != nil; } - if (refURL == nil && basePath && relativePath) { - NSURL *pathURL = [NSURL fileURLWithPath:[relativePath isAbsolutePath] ? relativePath : [basePath stringByAppendingPathComponent:relativePath]]; - refURL = (NSURL *)CFURLCreateFileReferenceURL(kCFAllocatorDefault, (CFURLRef)pathURL, NULL); - shouldUpdate = refURL != nil; + if (aURL == nil && basePath && relativePath) { + aURL = [[NSURL alloc] initFileURLWithPath:[relativePath isAbsolutePath] ? relativePath : [basePath stringByAppendingPathComponent:relativePath]]; + shouldUpdate = aURL != nil; } - if (refURL == nil) { + if (aURL == nil) { if ([alias isKindOfClass:[NSData class]]) { - NSURL *aURL = (NSURL *)CFURLCreateByResolvingBookmarkData(kCFAllocatorDefault, (CFDataRef)alias, kCFURLBookmarkResolutionWithoutUIMask | kCFURLBookmarkResolutionWithoutMountingMask, NULL, NULL, (Boolean *)&shouldUpdate, NULL); - if (aURL) { - refURL = (NSURL *)CFURLCreateFileReferenceURL(kCFAllocatorDefault, (CFURLRef)aURL, NULL); - [aURL release]; - } - shouldUpdate = shouldUpdate && basePath != nil && refURL != nil; + aURL = (NSURL *)CFURLCreateByResolvingBookmarkData(kCFAllocatorDefault, (CFDataRef)alias, kCFURLBookmarkResolutionWithoutUIMask | kCFURLBookmarkResolutionWithoutMountingMask, NULL, NULL, (Boolean *)&shouldUpdate, NULL); + shouldUpdate = shouldUpdate && basePath != nil && aURL != nil; } else if ([alias isKindOfClass:[BDSKAlias class]]) { FSRef aRef, baseRef; BOOL ignored, hasBaseRef = BDSKPathToFSRef(basePath, &baseRef); - if ([alias getFSRef:&aRef baseRef:hasBaseRef ? &baseRef : NULL shouldUpdate:&ignored]) { - NSURL *aURL = BDSKCreateURLFromFSRef(&aRef); - if (aURL) { - refURL = (NSURL *)CFURLCreateFileReferenceURL(kCFAllocatorDefault, (CFURLRef)aURL, NULL); - [aURL release]; - } - } - shouldUpdate = hasBaseRef && refURL != nil; + if ([alias getFSRef:&aRef baseRef:hasBaseRef ? &baseRef : NULL shouldUpdate:&ignored]) + aURL = BDSKCreateURLFromFSRef(&aRef); + shouldUpdate = hasBaseRef && aURL != nil; } } - if (refURL != nil) { - [fileRef release]; - fileRef = refURL; + if (aURL != nil) { + NSURL *refURL = (NSURL *)CFURLCreateFileReferenceURL(kCFAllocatorDefault, (CFURLRef)aURL, NULL); + [aURL release]; + shouldUpdate = shouldUpdate && basePath != nil && aURL != nil; + if (refURL != nil) { + [fileRef release]; + fileRef = refURL; + } } } else if (relativePath == nil) { shouldUpdate = basePath != nil; 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