Revision: 16753
          http://sourceforge.net/p/skim-app/code/16753
Author:   hofman
Date:     2026-10-30 17:31:38 +0000 (Fri, 30 Oct 2026)
Log Message:
-----------
get resource value from bookmark data from alias instead of custom properties

Modified Paths:
--------------
    trunk/SKAlias.h
    trunk/SKAlias.m
    trunk/SKBookmark.m

Modified: trunk/SKAlias.h
===================================================================
--- trunk/SKAlias.h     2026-10-30 17:04:01 UTC (rev 16752)
+++ trunk/SKAlias.h     2026-10-30 17:31:38 UTC (rev 16753)
@@ -49,8 +49,6 @@
 @property (nonatomic, readonly, getter=isBookmark) BOOL bookmark;
 @property (nonatomic, nullable, readonly) NSURL *fileURL;
 @property (nonatomic, nullable, readonly) NSURL *fileURLNoUI;
-@property (nonatomic, nullable, readonly) NSString *name;
-@property (nonatomic, nullable, readonly) NSString *fileType;
 
 - (nullable instancetype)initWithAliasData:(NSData *)data 
NS_DESIGNATED_INITIALIZER;
 - (nullable instancetype)initWithBookmarkData:(NSData *)data 
NS_DESIGNATED_INITIALIZER;
@@ -60,6 +58,8 @@
 // this is like [[self fileURLNoUI] isEqual:fileURL] but more efficient, 
assumes fileURL exists
 - (BOOL)resolvesToFileURL:(NSURL *)fileURL;
 
+- (nullable id)resourceValueForKey:(NSURLResourceKey)key;
+
 @end
 
 NS_ASSUME_NONNULL_END

Modified: trunk/SKAlias.m
===================================================================
--- trunk/SKAlias.m     2026-10-30 17:04:01 UTC (rev 16752)
+++ trunk/SKAlias.m     2026-10-30 17:31:38 UTC (rev 16753)
@@ -43,7 +43,7 @@
 
 @implementation SKAlias
 
-@dynamic data, bookmark, fileURL, fileURLNoUI, name;
+@dynamic data, bookmark, fileURL, fileURLNoUI;
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
@@ -136,6 +136,12 @@
     return aliasHandle == nil && data != nil;
 }
 
+- (id)resourceValueForKey:(NSURLResourceKey)key {
+    if (aliasHandle || data == nil)
+        return nil;
+    return [[NSURL resourceValuesForKeys:@[key] fromBookmarkData:data] 
objectForKey:key];
+}
+
 - (void)updateWithURL:(NSURL *)fileURL {
     NSData *bmData = [fileURL bookmarkDataWithOptions:0 
includingResourceValuesForKeys:nil relativeToURL:nil error:NULL];
     if (bmData) {
@@ -166,12 +172,12 @@
         fileURL = fileURLFromAliasHandle(aliasHandle, kResolveAliasFileNoUI);
         shouldUpdate = YES;
     } else if (data) {
-        NSString *path = [[[NSURL resourceValuesForKeys:@[NSURLPathKey] 
fromBookmarkData:data] objectForKey:NSURLPathKey] stringByStandardizingPath];
+        NSString *path = [[self resourceValueForKey:NSURLPathKey] 
stringByStandardizingPath];
         if (path) {
             fileURL = [NSURL fileURLWithPath:path isDirectory:[[path 
pathExtension] isCaseInsensitiveEqual:@"pdfd"]];
             if ([fileURL checkResourceIsReachableAndReturnError:NULL]) {
                 NSNumber *fileID = nil;
-                NSNumber *myFileID = [[NSURL 
resourceValuesForKeys:@[NSURLFileIDKey] fromBookmarkData:data] 
objectForKey:NSURLFileIDKey];
+                NSNumber *myFileID = [self resourceValueForKey:NSURLFileIDKey];
                 if (myFileID && [fileURL getResourceValue:&fileID 
forKey:NSURLFileIDKey error:NULL] && [fileID isEqual:myFileID] == NO)
                     shouldUpdate = YES;
             } else {
@@ -235,22 +241,4 @@
     return [[myFileURL path] isCaseInsensitiveEqual:[fileURL path]];
 }
 
-- (NSString *)name {
-    NSString *name = nil;
-    NSURL *fileURL = [self fileURLNoUI];
-    if ((fileURL == nil || NO == [fileURL getResourceValue:&name 
forKey:NSURLLocalizedNameKey error:NULL]) && aliasHandle == nil)
-        name = [[NSURL resourceValuesForKeys:@[NSURLNameKey] 
fromBookmarkData:data] objectForKey:NSURLNameKey] ?: [[[NSURL 
resourceValuesForKeys:@[NSURLPathKey] fromBookmarkData:data] 
objectForKey:NSURLPathKey] lastPathComponent];
-    return name;
-}
-
-- (NSString *)fileType {
-    NSString *type = nil;
-    NSURL *fileURL = [self fileURLNoUI];
-    if (fileURL)
-        type = [[NSWorkspace sharedWorkspace] typeOfFile:[fileURL path] 
error:NULL];
-    else if (aliasHandle == nil && (type = [[[NSURL 
resourceValuesForKeys:@[NSURLPathKey] fromBookmarkData:data] 
objectForKey:NSURLPathKey] pathExtension]))
-        type = 
CFBridgingRelease(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,
 (__bridge CFStringRef)type, NULL));
-    return type;
-}
-
 @end

Modified: trunk/SKBookmark.m
===================================================================
--- trunk/SKBookmark.m  2026-10-30 17:04:01 UTC (rev 16752)
+++ trunk/SKBookmark.m  2026-10-30 17:31:38 UTC (rev 16753)
@@ -549,7 +549,13 @@
 }
 
 - (NSImage *)icon {
-    return [[self class] iconForFileType:[alias fileType] hasSetup:[setup 
objectForKey:SKDocumentSetupWindowFrameKey] != nil];
+    NSString *type = nil;
+    NSURL *fileURL = [self fileURL];
+    if (fileURL)
+        type = [[NSWorkspace sharedWorkspace] typeOfFile:[fileURL path] 
error:NULL];
+    else if ((type = [[alias resourceValueForKey:NSURLPathKey] pathExtension]))
+        type = 
CFBridgingRelease(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,
 (__bridge CFStringRef)type, NULL));
+    return [[self class] iconForFileType:type hasSetup:[setup 
objectForKey:SKDocumentSetupWindowFrameKey] != nil];
 }
 
 - (NSUInteger)pageIndex {
@@ -570,8 +576,12 @@
 
 - (NSString *)label {
     NSString *theLabel = label;
-    if ([theLabel length] == 0)
-        theLabel = [alias name];
+    if ([theLabel length] == 0) {
+        NSURL *fileURL = [self fileURL];
+        if ((fileURL == nil || NO == [fileURL getResourceValue:&theLabel 
forKey:NSURLLocalizedNameKey error:NULL]))
+            theLabel = [alias resourceValueForKey:NSURLNameKey] ?: [[alias 
resourceValueForKey:NSURLPathKey] lastPathComponent];
+
+    }
     return theLabel ?: @"";
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to