JNIEXPORT void JNICALL Java_io_realm_internal_Group_nativeWriteToFile( JNIEnv* env, jobject, jlong nativeGroupPtr, jstring jFileName, jbyteArray keyArray) { TR_ENTER_PTR(nativeGroupPtr) StringData file_name; KeyBuffer key(env, keyArray); try { JStringAccessor file_name_tmp(env, jFileName); // throws file_name = StringData(file_name_tmp); #ifdef REALM_ENABLE_ENCRYPTION G(nativeGroupPtr)->write(file_name, key.data()); #else G(nativeGroupPtr)->write(file_name); #endif } CATCH_FILE(file_name) CATCH_STD() }
#define G(x) reinterpret_cast<realm::Group*>(x)
Group.java
/** * Serializes the group to the specific file on the disk using encryption. * * @param file a File object representing the file. * @param key A 64 bytes long byte array containing the key to the encrypted Realm file. Can be null if encryption * is not required. * @throws IOException. */ public void writeToFile(File file, byte[] key) throws IOException { verifyGroupIsValid(); if (file.isFile() && file.exists()) { throw new IllegalArgumentException("The destination file must not exist"); } if (key != null && key.length != 64) { throw new IllegalArgumentException("Realm AES keys must be 64 bytes long"); } nativeWriteToFile(nativePtr, file.getAbsolutePath(), key); }
public Group() { this.immutable = false; this.context = new Context(); this.nativePtr = createNative(); checkNativePtrNotZero(); }
JNIEXPORT jlong JNICALL Java_io_realm_internal_Group_createNative__( JNIEnv*, jobject) { TR_ENTER() Group *ptr = new Group(); TR("Group::createNative(): %p.", VOID_PTR(ptr)) return reinterpret_cast<jlong>(ptr); }
CPP代码Group的实现在哪里?
源码中多次出现的
#include <realm/util/safe_int_ops.hpp>
在源码目录中为何找不到?
时间: 2024-10-25 20:40:28