Created
June 29, 2012 22:30
-
-
Save kristopherjohnson/3021077 to your computer and use it in GitHub Desktop.
NSData category that determines whether data is ZIP format
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
@implementation NSData (ZipFile) | |
- (BOOL)isZipFormatData { | |
// Zip files start with the bytes { 50, 4b, 03, 04 } | |
if (self.length < 4) | |
return NO; | |
unsigned char signature[4]; | |
[self getBytes:signature length:sizeof(signature)]; | |
return (signature[0] == 0x50) && | |
(signature[1] == 0x4b) && | |
(signature[2] == 0x03) && | |
(signature[3] == 0x04); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment