Skip to content

Commit

Permalink
Remove archive detection
Browse files Browse the repository at this point in the history
Summary: This isn't needed anymore.

Reviewed By: zeyadsalloum

Differential Revision: D15118792

fbshipit-source-id: 1074a8eab40dc9ebf9a64eeb86d43e435cce422b
  • Loading branch information
lawrencelomax authored and facebook-github-bot committed Apr 29, 2019
1 parent 7d630bb commit d73c9cc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 64 deletions.
25 changes: 0 additions & 25 deletions FBControlCore/Utility/FBArchiveOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ NS_ASSUME_NONNULL_BEGIN

@class FBProcessInput;

/**
Enumerations for possible header magic numbers in files & data.
*/
typedef enum {
FBFileHeaderMagicUnknown = 0,
FBFileHeaderMagicGZIP = 1,
FBFileHeaderMagicIPA = 2,
} FBFileHeaderMagic;

/**
Operations of Zip/Tar Archives
*/
Expand Down Expand Up @@ -103,22 +94,6 @@ typedef enum {
*/
+ (FBFuture<NSData *> *)createGzippedTarDataForPath:(NSString *)path queue:(dispatch_queue_t)queue logger:(id<FBControlCoreLogger>)logger;

/**
Get the header magic from some data.
@param data the data to check.
@return the header magic if one could be deduced.
*/
+ (FBFileHeaderMagic)headerMagicForData:(NSData *)data;

/**
Get the header magic from a file
@param path the file to checked
@return the header magic if one could be deduced.
*/
+ (FBFileHeaderMagic)headerMagicForFile:(NSString *)path;

@end

NS_ASSUME_NONNULL_END
39 changes: 0 additions & 39 deletions FBControlCore/Utility/FBArchiveOperations.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,47 +91,8 @@ @implementation FBArchiveOperations
}];
}


// The Magic Header for Zip Files is two chars 'PK'. As a short this is as below.
static unsigned short const ZipFileMagicHeader = 0x4b50;
// The Magic Header for Tar Files
static unsigned short const TarFileMagicHeader = 0x8b1f;

+ (FBFileHeaderMagic)headerMagicForData:(NSData *)data
{
unsigned short magic = 0;
[data getBytes:&magic length:sizeof(short)];
return [self magicForShort:magic];
}

+ (FBFileHeaderMagic)headerMagicForFile:(NSString *)path
{
// IPAs are Zip files. Zip Files always have a magic header in their first 4 bytes.
FILE *file = fopen(path.UTF8String, "r");
if (!file) {
return FBFileHeaderMagicUnknown;
}
unsigned short magic = 0;
if (!fread(&magic, sizeof(short), 1, file)) {
fclose(file);
return FBFileHeaderMagicUnknown;
}
fclose(file);
return [self magicForShort:magic];
}

#pragma mark Private

+ (FBFileHeaderMagic)magicForShort:(unsigned short)magic
{
if (magic == ZipFileMagicHeader) {
return FBFileHeaderMagicIPA;
} else if (magic == TarFileMagicHeader) {
return FBFileHeaderMagicGZIP;
}
return FBFileHeaderMagicUnknown;
}

+ (FBTaskBuilder<NSNull *, NSData *, id<FBControlCoreLogger>> *)createGzippedTarTaskBuilderForPath:(NSString *)path queue:(dispatch_queue_t)queue logger:(id<FBControlCoreLogger>)logger error:(NSError **)error
{
BOOL isDirectory;
Expand Down

0 comments on commit d73c9cc

Please sign in to comment.