-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcpp-adapter.cpp
More file actions
48 lines (38 loc) · 2.08 KB
/
cpp-adapter.cpp
File metadata and controls
48 lines (38 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <jni.h>
#include "react-native-bs-diff-patch.h"
static jint bsDiffFileJNI(JNIEnv *env, jstring oldFile_, jstring newFile_, jstring patchFile_) {
const char *oldFile = env->GetStringUTFChars(oldFile_, 0);
const char *newFile = env->GetStringUTFChars(newFile_, 0);
const char *patchFile = env->GetStringUTFChars(patchFile_, 0);
int result = bsdiffpatch::diffFile(oldFile, newFile, patchFile);
env->ReleaseStringUTFChars(oldFile_, oldFile);
env->ReleaseStringUTFChars(newFile_, newFile);
env->ReleaseStringUTFChars(patchFile_, patchFile);
return result;
}
static jint bsPatchFileJNI(JNIEnv *env, jstring oldFile_, jstring newFile_, jstring patchFile_) {
const char *oldFile = env->GetStringUTFChars(oldFile_, 0);
const char *newFile = env->GetStringUTFChars(newFile_, 0);
const char *patchFile = env->GetStringUTFChars(patchFile_, 0);
int result = bsdiffpatch::patchFile(oldFile, newFile, patchFile);
env->ReleaseStringUTFChars(oldFile_, oldFile);
env->ReleaseStringUTFChars(newFile_, newFile);
env->ReleaseStringUTFChars(patchFile_, patchFile);
return result;
}
extern "C" JNIEXPORT jint JNICALL
Java_com_jimmydaddy_bsdiffpatch_BsDiffPatchNative_bsDiffFile(JNIEnv *env,
jobject type,
jstring oldFile_,
jstring newFile_,
jstring patchFile_) {
return bsDiffFileJNI(env, oldFile_, newFile_, patchFile_);
}
extern "C" JNIEXPORT jint JNICALL
Java_com_jimmydaddy_bsdiffpatch_BsDiffPatchNative_bsPatchFile(JNIEnv *env,
jobject type,
jstring oldFile_,
jstring newFile_,
jstring patchFile_) {
return bsPatchFileJNI(env, oldFile_, newFile_, patchFile_);
}