Re: Determine whether a file has a custom icon
Re: Determine whether a file has a custom icon
- Subject: Re: Determine whether a file has a custom icon
- From: Rainer Brockerhoff <email@hidden>
- Date: Mon, 3 Dec 2007 22:14:33 -0200
At 15:49 -0800 03/12/2007, email@hidden wrote:
>From: Adrian Ross <email@hidden>
>Date: Tue, 4 Dec 2007 12:07:54 +1300
>Message-ID: <email@hidden>
>
>Can anyone help me determine whether a file or folder has a custom icon? For example, I'd like to know whether the Finder would display the default folder icon for a given folder, or some other icon.
>
>I know I can use +iconForFile in NSWorkspace to get an NSImage of the icon in question, but I don't know how to tell whether this is a default icon or a custom one.
>
>A previous proposed solution on this list was to use kHasCustomIcon in the Finder flags. This is rarely set and doesn't do the trick.
Depends on what sort of "custom icon" you mean. kHasCustomIcon is set when an actual custom icon was pasted into the Finder's Get Info window.
Then there are the special icons displayed for certain folders, like /Applications, ~/Downloads and so forth. The generic way to test for these is to obtain a FSRef for the folder, then call GetIconRefFromFileInfo() on it. Then you can (for instance) get the IconRef for the generic folder by calling GetIconRefFromTypeInfo(kSystemIconsCreator,kGenericFolderIcon...) and compare if they're equal.
HTH,
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
Weblog: http://www.brockerhoff.net/bb/viewtopic.php
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden