⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svnclient.cpp

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            if(JNIUtil::isJavaExceptionThrown())            {                return NULL;            }            jConflictNew = JNIUtil::makeJString(entry->conflict_new);            if(JNIUtil::isJavaExceptionThrown())            {                return NULL;            }            jConflictOld = JNIUtil::makeJString(entry->conflict_old);            if(JNIUtil::isJavaExceptionThrown())            {                return NULL;            }            jConflictWorking= JNIUtil::makeJString(entry->conflict_wrk);            if(JNIUtil::isJavaExceptionThrown())            {                return NULL;            }            jURLCopiedFrom = JNIUtil::makeJString(entry->copyfrom_url);            if(JNIUtil::isJavaExceptionThrown())            {                return NULL;            }            jRevisionCopiedFrom = entry->copyfrom_rev;            jLockToken = JNIUtil::makeJString(entry->lock_token);            if(JNIUtil::isJavaExceptionThrown())            {                return NULL;            }            jLockComment = JNIUtil::makeJString(entry->lock_comment);            if(JNIUtil::isJavaExceptionThrown())            {                return NULL;            }            jLockOwner = JNIUtil::makeJString(entry->lock_owner);            if(JNIUtil::isJavaExceptionThrown())            {                return NULL;            }            jLockCreationDate = entry->lock_creation_date;        }    }    jobject ret = env->NewObject(clazz, mid, jPath, jUrl, jNodeKind, jRevision,         jLastChangedRevision, jLastChangedDate, jLastCommitAuthor,        jTextType, jPropType, jRepositoryTextType, jRepositoryPropType,         jIsLocked, jIsCopied, jConflictOld, jConflictNew, jConflictWorking,        jURLCopiedFrom, jRevisionCopiedFrom, jIsSwitched, jLockToken,         jLockOwner, jLockComment, jLockCreationDate, jLock,        jOODLastCmtRevision, jOODLastCmtDate, jOODKind, jOODLastCmtAuthor);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(clazz);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jPath);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jUrl);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jLastCommitAuthor);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jConflictNew);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jConflictOld);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jConflictWorking);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jURLCopiedFrom);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jLockComment);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jLockOwner);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jLockToken);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jLock);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jOODLastCmtAuthor);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    return ret;}svn_error_t *SVNClient::messageReceiver (void *baton, apr_hash_t *changed_paths,                 svn_revnum_t rev, const char *author, const char *date,                 const char *msg, apr_pool_t * pool){    if(JNIUtil::isJavaExceptionThrown())    {        return SVN_NO_ERROR;    }    std::vector<jobject> *logs = (std::vector<jobject>*)baton;    static jmethodID mid = 0;    JNIEnv *env = JNIUtil::getEnv();    jclass clazz = env->FindClass(JAVA_PACKAGE"/LogMessage");    if(JNIUtil::isJavaExceptionThrown())    {        return SVN_NO_ERROR;    }    if(mid == 0)    {        mid = env->GetMethodID(clazz, "<init>",            "(Ljava/lang/String;Ljava/util/Date;JLjava/lang/String;"            "[Lorg/tigris/subversion/javahl/ChangePath;)V");        if(JNIUtil::isJavaExceptionThrown() || mid == 0)        {            return SVN_NO_ERROR;        }    }    jclass clazzCP = env->FindClass(JAVA_PACKAGE"/ChangePath");    if(JNIUtil::isJavaExceptionThrown())    {        return SVN_NO_ERROR;    }    static jmethodID midCP = 0;    if(midCP == 0)    {        midCP = env->GetMethodID(clazzCP, "<init>",            "(Ljava/lang/String;JLjava/lang/String;C)V");        if(JNIUtil::isJavaExceptionThrown() || mid == 0)        {            return SVN_NO_ERROR;        }    }    jstring jmessage = JNIUtil::makeJString(msg);    if(JNIUtil::isJavaExceptionThrown())    {        return SVN_NO_ERROR;    }    jobject jdate = NULL;    if(date != NULL && *date != '\0')    {        apr_time_t timeTemp;                svn_error_t * err = svn_time_from_cstring (&timeTemp, date, pool);        if(err != SVN_NO_ERROR)            return err;        jdate = JNIUtil::createDate(timeTemp);        if(JNIUtil::isJavaExceptionThrown())        {            return SVN_NO_ERROR;        }    }    jstring jauthor = JNIUtil::makeJString(author);    if(JNIUtil::isJavaExceptionThrown())    {        return SVN_NO_ERROR;    }    jobjectArray jChangedPaths = NULL;    if (changed_paths)    {        apr_array_header_t *sorted_paths;        int i;        /* Get an array of sorted hash keys. */        sorted_paths = svn_sort__hash (changed_paths,                                     svn_sort_compare_items_as_paths, pool);        jChangedPaths = env->NewObjectArray(sorted_paths->nelts, clazzCP, NULL);        for (i = 0; i < sorted_paths->nelts; i++)        {            svn_sort__item_t *item = &(APR_ARRAY_IDX (sorted_paths, i,                                                    svn_sort__item_t));            const char *path = (const char *)item->key;            svn_log_changed_path_t *log_item                 = (svn_log_changed_path_t *)                    apr_hash_get (changed_paths, item->key, item->klen);            jstring jpath = JNIUtil::makeJString(path);            if(JNIUtil::isJavaExceptionThrown())            {                return SVN_NO_ERROR;            }            jstring jcopyFromPath =                 JNIUtil::makeJString(log_item->copyfrom_path);            if(JNIUtil::isJavaExceptionThrown())            {                return SVN_NO_ERROR;            }            jlong jcopyFromRev = log_item->copyfrom_rev;            jchar jaction = log_item->action;            jobject cp = env->NewObject(clazzCP, midCP, jpath, jcopyFromRev,                jcopyFromPath, jaction);            if(JNIUtil::isJavaExceptionThrown())            {                return SVN_NO_ERROR;            }            env->SetObjectArrayElement(jChangedPaths, i, cp);            if(JNIUtil::isJavaExceptionThrown())            {                return SVN_NO_ERROR;            }            env->DeleteLocalRef(cp);            if(JNIUtil::isJavaExceptionThrown())            {                return SVN_NO_ERROR;            }            env->DeleteLocalRef(jpath);            if(JNIUtil::isJavaExceptionThrown())            {                return SVN_NO_ERROR;            }            env->DeleteLocalRef(jcopyFromPath);            if(JNIUtil::isJavaExceptionThrown())            {                return SVN_NO_ERROR;            }        }    }    jobject log = env->NewObject(clazz, mid, jmessage, jdate, (jlong)rev,                                  jauthor, jChangedPaths);    if(JNIUtil::isJavaExceptionThrown())    {        return SVN_NO_ERROR;    }    logs->push_back(log);    env->DeleteLocalRef(jChangedPaths);    if(JNIUtil::isJavaExceptionThrown())    {        return SVN_NO_ERROR;    }    env->DeleteLocalRef(clazz);    if(JNIUtil::isJavaExceptionThrown())    {        return SVN_NO_ERROR;    }    env->DeleteLocalRef(jmessage);    if(JNIUtil::isJavaExceptionThrown())    {        return SVN_NO_ERROR;    }    env->DeleteLocalRef(jdate);    if(JNIUtil::isJavaExceptionThrown())    {        return SVN_NO_ERROR;    }    env->DeleteLocalRef(jauthor);    return SVN_NO_ERROR;}jobject SVNClient::createJavaProperty(jobject jthis, const char *path,                                       const char *name, svn_string_t *value){    JNIEnv *env = JNIUtil::getEnv();    jclass clazz = env->FindClass(JAVA_PACKAGE"/PropertyData");    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    static jmethodID mid = 0;    if(mid == 0)    {        mid = env->GetMethodID(clazz, "<init>",                   "(L"JAVA_PACKAGE"/SVNClient;Ljava/lang/String;"                   "Ljava/lang/String;Ljava/lang/String;[B)V");        if(JNIUtil::isJavaExceptionThrown())        {            return NULL;        }    }    jstring jPath = JNIUtil::makeJString(path);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    jstring jName = JNIUtil::makeJString(name);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    jstring jValue = JNIUtil::makeJString(value->data);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    jbyteArray jData = JNIUtil::makeJByteArray((const signed char *)value->data,                                                value->len);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    jobject ret = env->NewObject(clazz, mid, jthis, jPath, jName, jValue,                                  jData);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(clazz);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jPath);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jName);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jValue);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    env->DeleteLocalRef(jData);    if(JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    return ret;}void SVNClient::propertySet(const char *path, const char *name,                             svn_string_t *value, bool recurse, bool force){    Path intPath(path);    svn_error_t *Err = intPath.error_occured();    if(Err != NULL)    {        JNIUtil::handleSVNError(Err);        return;    }    svn_client_ctx_t *ctx = getContext(NULL);    if(ctx == NULL)        return;    Err = svn_client_propset2 (name, value,                                 intPath.c_str(),                                recurse,                                 force,                                ctx,                                JNIUtil::getRequestPool()->pool());    if(Err!= NULL)        JNIUtil::handleSVNError(Err);}jbyteArray SVNClient::fileContent(const char *path, Revision &revision,                                  Revision &pegRevision){    Pool requestPool;    if(path == NULL)    {        JNIUtil::throwNullPointerException("path");        return NULL;    }    Path intPath(path);    svn_error_t *Err = intPath.error_occured();    if(Err != NULL)    {        JNIUtil::handleSVNError(Err);        return NULL;    }    size_t size = 0;    svn_stream_t *read_stream = createReadStream(requestPool.pool(),						 intPath.c_str(), revision,						 pegRevision, size);    if (read_stream == NULL)    {        return NULL;    }    JNIEnv *env = JNIUtil::getEnv();    // size will be set to the number of bytes available.    jbyteArray ret = env->NewByteArray(size);    if (JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    jbyte *retdata = env->GetByteArrayElements(ret, NULL);    if (JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    Err = svn_stream_read(read_stream, (char *)retdata, &size);    env->ReleaseByteArrayElements(ret, retdata, 0);    if (Err != NULL)    {        JNIUtil::handleSVNError(Err);        return NULL;    }    if (JNIUtil::isJavaExceptionThrown())    {        return NULL;    }    return ret;}void SVNClient::streamFileContent(const char *path, Revision &revision,				  Revision &pegRevision, jobject outputStream,				  size_t bufSize){    Pool requestPool;    if (path == NULL)    {        JNIUtil::throwNullPointerException("path");        return;    }    Path intPath(path);    svn_error_t *Err = intPath.error_occured();    if (Err != NULL)    {        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -