2016-04-02 14:24:33 +08:00
|
|
|
//
|
|
|
|
// BSDiff.m
|
2019-11-16 00:31:30 +08:00
|
|
|
// RCTPushy
|
2016-04-02 14:24:33 +08:00
|
|
|
//
|
|
|
|
// 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];
|
|
|
|
}
|
|
|
|
|
2016-04-05 15:25:45 +08:00
|
|
|
int err = beginPatch([origin UTF8String], [destination UTF8String], [patch UTF8String]);
|
|
|
|
if (err) {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
return YES;
|
2016-04-02 14:24:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|