Last active
December 17, 2015 14:19
-
-
Save mattstevens/5623680 to your computer and use it in GitHub Desktop.
Check for existence of a custom icon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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