Skip to content

Instantly share code, notes, and snippets.

@kristopherjohnson
Created June 29, 2012 22:30
Show Gist options
  • Save kristopherjohnson/3021077 to your computer and use it in GitHub Desktop.
Save kristopherjohnson/3021077 to your computer and use it in GitHub Desktop.
NSData category that determines whether data is ZIP format
@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