1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
react-native-pushy/ios/RCTHotUpdate/BSDiff/BSDiff.m
2016-04-05 15:25:45 +08:00

38 lines
830 B
Objective-C

//
// BSDiff.m
// RCTHotUpdate
//
// Created by lvbingru on 16/4/2.
// Copyright © 2016年 erica. All rights reserved.
//
#import "BSDiff.h"
#include "bspatch.h"
@implementation BSDiff
+ (BOOL)bsdiffPatch:(NSString *)patch
origin:(NSString *)origin
toDestination:(NSString *)destination
{
if (![[NSFileManager defaultManager] fileExistsAtPath:patch]) {
return NO;
}
if (![[NSFileManager defaultManager] fileExistsAtPath:origin]) {
return NO;
}
if ([[NSFileManager defaultManager] fileExistsAtPath:destination]) {
[[NSFileManager defaultManager] removeItemAtPath:destination error:nil];
}
int err = beginPatch([origin UTF8String], [destination UTF8String], [patch UTF8String]);
if (err) {
return NO;
}
return YES;
}
@end