Skip to content

Instantly share code, notes, and snippets.

@mattstevens
Last active December 17, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattstevens/5623680 to your computer and use it in GitHub Desktop.
Save mattstevens/5623680 to your computer and use it in GitHub Desktop.
Check for existence of a custom icon
- (BOOL)fileHasCustomIcon:(NSString *)path {
struct FinderInfoAttrBuf {
u_int32_t length;
FileInfo fileInfo;
ExtendedFileInfo extendedFileInfo;
} __attribute__((aligned(4), packed));
struct attrlist attrList = {};
struct FinderInfoAttrBuf attrBuf = {};
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
attrList.commonattr = ATTR_CMN_FNDRINFO;
if (getattrlist([path fileSystemRepresentation], &attrList, &attrBuf, sizeof(attrBuf), 0) != 0)
return NO;
return !!(OSSwapBigToHostInt16(attrBuf.fileInfo.finderFlags) & kHasCustomIcon);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment