Revision: 26857
          http://sourceforge.net/p/bibdesk/svn/26857
Author:   hofman
Date:     2021-09-12 23:08:45 +0000 (Sun, 12 Sep 2021)
Log Message:
-----------
Reorganize code

Modified Paths:
--------------
    trunk/bibdesk/BDSKLinkedFile.m

Modified: trunk/bibdesk/BDSKLinkedFile.m
===================================================================
--- trunk/bibdesk/BDSKLinkedFile.m      2021-09-12 17:13:14 UTC (rev 26856)
+++ trunk/bibdesk/BDSKLinkedFile.m      2021-09-12 23:08:45 UTC (rev 26857)
@@ -492,15 +492,6 @@
     }
 }
 
-// this is really implemented by the subclasses
-- (void)updateFileURL {
-    if (fileURL == nil && relativePath) {
-        NSString *basePath = [delegate basePathForLinkedFile:self];
-        if (basePath)
-            fileURL = [[NSURL alloc] initFileURLWithPath:[relativePath 
isAbsolutePath] ? relativePath : [[basePath 
stringByAppendingPathComponent:relativePath] stringByStandardizingPath]];
-    }
-}
-
 - (NSURL *)URL {
     [self updateFileURL];
     return fileURL;
@@ -578,6 +569,9 @@
         return [[NSPropertyListSerialization dataWithPropertyList:dictionary 
format:NSPropertyListBinaryFormat_v1_0 options:0 error:NULL] base64String];
 }
 
+// this is implemented by the subclasses
+- (void)updateFileURL {}
+
 // This is called when the file is added (new or initially),
 // the document URL changes, or with aPath != nil after an autofile
 // implemented by the subclasses
@@ -736,28 +730,6 @@
     [aURL release];
 }
 
-- (NSData *)copyAliasDataRelativeToPath:(NSString *)basePath {
-    BDSKAlias *anAlias = NULL;
-    NSData *data = nil;
-    
-    if (fileRef) {
-        FSRef baseRef;
-        BOOL hasBaseRef = BDSKPathToFSRef(basePath, &baseRef);
-        anAlias = [BDSKAlias newWithFSRef:fileRef baseRef:hasBaseRef ? 
&baseRef : NULL];
-    } else if (relativePath && basePath) {
-        NSString *path = [relativePath isAbsolutePath] ? relativePath : 
[[basePath stringByAppendingPathComponent:relativePath] 
stringByStandardizingPath];
-        anAlias = [BDSKAlias newWithPath:path basePath:basePath];
-    }
-    if (anAlias != NULL) {
-        data = [anAlias copyData];
-        [anAlias release];
-    } else if ([alias isKindOfClass:[BDSKAlias class]]) {
-        data = [alias copyData];
-    }
-    
-    return data;
-}
-
 - (void)setAliasWithPath:(NSString *)aPath basePath:(NSString *)basePath {
     id anAlias = [BDSKAlias newWithPath:aPath basePath:basePath];
     if (anAlias != nil) {
@@ -835,6 +807,28 @@
     isInitial = NO;
 }
 
+- (NSData *)copyAliasDataRelativeToPath:(NSString *)basePath {
+    BDSKAlias *anAlias = NULL;
+    NSData *data = nil;
+    
+    if (fileRef) {
+        FSRef baseRef;
+        BOOL hasBaseRef = BDSKPathToFSRef(basePath, &baseRef);
+        anAlias = [BDSKAlias newWithFSRef:fileRef baseRef:hasBaseRef ? 
&baseRef : NULL];
+    } else if (relativePath && basePath) {
+        NSString *path = [relativePath isAbsolutePath] ? relativePath : 
[[basePath stringByAppendingPathComponent:relativePath] 
stringByStandardizingPath];
+        anAlias = [BDSKAlias newWithPath:path basePath:basePath];
+    }
+    if (anAlias != NULL) {
+        data = [anAlias copyData];
+        [anAlias release];
+    } else if ([alias isKindOfClass:[BDSKAlias class]]) {
+        data = [alias copyData];
+    }
+    
+    return data;
+}
+
 @end
 
 #pragma mark -
@@ -947,27 +941,6 @@
     }
 }
 
-- (NSData *)copyDataRelativeToPath:(NSString *)newBasePath isBookmark:(BOOL 
*)isBookmark {
-    NSData *data = nil;
-    
-    if (fileURL) {
-        data = BDSKCreateBookmarkDataFromURL(fileURL);
-    } else if (relativePath && newBasePath) {
-        NSURL *aURL = [NSURL fileURLWithPath:[relativePath isAbsolutePath] ? 
relativePath : [[newBasePath stringByAppendingPathComponent:relativePath] 
stringByStandardizingPath]];
-        data = BDSKCreateBookmarkDataFromURL(aURL);
-    }
-    if (data == nil && [alias isKindOfClass:[NSData class]])
-        data = [alias copy];
-    
-    if (data) {
-        *isBookmark = YES;
-    } else if ([alias isKindOfClass:[BDSKAlias class]]) {
-        data = [alias copyData];
-        *isBookmark = NO;
-    }
-    return data;
-}
-
 // This is called when the file is added (new or initially),
 // the document URL changes, or with aPath != nil after an autofile
 - (void)updateWithPath:(NSString *)aPath {
@@ -1013,6 +986,27 @@
     isInitial = NO;
 }
 
+- (NSData *)copyDataRelativeToPath:(NSString *)newBasePath isBookmark:(BOOL 
*)isBookmark {
+    NSData *data = nil;
+    
+    if (fileURL) {
+        data = BDSKCreateBookmarkDataFromURL(fileURL);
+    } else if (relativePath && newBasePath) {
+        NSURL *aURL = [NSURL fileURLWithPath:[relativePath isAbsolutePath] ? 
relativePath : [[newBasePath stringByAppendingPathComponent:relativePath] 
stringByStandardizingPath]];
+        data = BDSKCreateBookmarkDataFromURL(aURL);
+    }
+    if (data == nil && [alias isKindOfClass:[NSData class]])
+        data = [alias copy];
+    
+    if (data) {
+        *isBookmark = YES;
+    } else if ([alias isKindOfClass:[BDSKAlias class]]) {
+        data = [alias copyData];
+        *isBookmark = NO;
+    }
+    return data;
+}
+
 @end
 
 #pragma mark -

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

Reply via email to