码迷,mamicode.com
首页 > 编程语言 > 详细

realm java 源码疑问

时间:2016-05-21 14:13:38      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

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>

在源码目录中为何找不到?

realm java 源码疑问

标签:

原文地址:http://www.cnblogs.com/zhhd/p/5514538.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!