Author: rmottola
Date: Tue Mar  8 15:19:07 2016
New Revision: 39480

URL: http://svn.gna.org/viewcvs/gnustep?rev=39480&view=rev
Log:
When looking for an icon, check if it is a symbolic link and get the icon of 
its destination. Behaviour verified on Apple

Modified:
    libs/gui/trunk/ChangeLog
    libs/gui/trunk/Source/NSWorkspace.m

Modified: libs/gui/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=39480&r1=39479&r2=39480&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog    (original)
+++ libs/gui/trunk/ChangeLog    Tue Mar  8 15:19:07 2016
@@ -1,3 +1,8 @@
+2016-03-08 Riccardo Mottola <[email protected]>
+
+       * Source/NSWorkspace.m (iconForFile)
+       When looking for an icon, check if it is a symbolic link and get the 
icon of its destination. Behaviour verified on Apple.
+
 2016-02-16 Riccardo Mottola <[email protected]>
 
        * Source/NSWorkspace.m (mountNewRemovableMedia)

Modified: libs/gui/trunk/Source/NSWorkspace.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSWorkspace.m?rev=39480&r1=39479&r2=39480&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSWorkspace.m (original)
+++ libs/gui/trunk/Source/NSWorkspace.m Tue Mar  8 15:19:07 2016
@@ -1365,8 +1365,29 @@
   NSDictionary *attributes;
   NSString     *fileType;
 
-  attributes = [mgr fileAttributesAtPath: fullPath traverseLink: YES];
-  fileType = [attributes objectForKey: NSFileType];
+  attributes = [mgr fileAttributesAtPath: fullPath traverseLink: NO];
+  fileType = [attributes fileType];
+
+  /*
+    If we have a symobolic link, get not only the original path attributes,
+    but also the original path, to resolve the correct icon.
+    mac resolves the original icon
+  */
+  if ([fileType isEqual: NSFileTypeSymbolicLink] == YES)
+    {
+      NSString *linkPath;
+      
+      linkPath = [mgr pathContentOfSymbolicLinkAtPath:fullPath];
+      if ([linkPath isAbsolutePath])
+       fullPath = linkPath;
+      else
+       fullPath = [[[fullPath stringByDeletingLastPathComponent] 
stringByAppendingPathComponent:linkPath] stringByStandardizingPath];
+
+      /* now we reget the target attributes */
+      attributes = [mgr fileAttributesAtPath: fullPath traverseLink: NO];
+      fileType = [attributes fileType];
+    }
+  
   if ([fileType isEqual: NSFileTypeDirectory] == YES)
     {
       NSString *iconPath = nil;


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to