Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/javahl/native/JNIUtil.cpp view on Meta::CPAN
&& (err->apr_err <= APR_OS_START_CANONERR))
buffer.append(svn_strerror(err->apr_err, errbuf, sizeof(errbuf)));
/* Otherwise, this must be an APR error code. */
else
{
/* Messages coming from apr_strerror are in the native
encoding, it's a good idea to convert them to UTF-8. */
const char* utf8_message;
apr_strerror(err->apr_err, errbuf, sizeof(errbuf));
svn_error_t* utf8_err = svn_utf_cstring_to_utf8(
&utf8_message, errbuf, err->pool);
if (utf8_err)
{
/* Use fuzzy transliteration instead. */
svn_error_clear(utf8_err);
utf8_message = svn_utf_cstring_from_utf8_fuzzy(errbuf, err->pool);
}
buffer.append(utf8_message);
}
buffer.append("\n");
}
if (err->message)
buffer.append(_("svn: ")).append(err->message).append("\n");
if (err->child)
assembleErrorMessage(err->child, depth + 1, err->apr_err, buffer);
}
/**
* Throw a Java NullPointerException. Used when input parameters
* which should not be null are that.
*
* @param message the name of the parameter that is null
*/
void JNIUtil::throwNullPointerException(const char *message)
{
if (getLogLevel() >= errorLog)
logMessage("NullPointerException thrown");
JNIEnv *env = getEnv();
jclass clazz = env->FindClass("java/lang/NullPointerException");
if (isJavaExceptionThrown())
return;
env->ThrowNew(clazz, message);
setExceptionThrown();
env->DeleteLocalRef(clazz);
}
svn_error_t *JNIUtil::preprocessPath(const char *&path, apr_pool_t *pool)
{
/* URLs and wc-paths get treated differently. */
if (svn_path_is_url(path))
{
/* No need to canonicalize a URL's case or path separators. */
/* Convert to URI. */
path = svn_path_uri_from_iri(path, pool);
/* Auto-escape some ASCII characters. */
path = svn_path_uri_autoescape(path, pool);
/* The above doesn't guarantee a valid URI. */
if (! svn_path_is_uri_safe(path))
return svn_error_createf(SVN_ERR_BAD_URL, NULL,
_("URL '%s' is not properly URI-encoded"),
path);
/* Verify that no backpaths are present in the URL. */
if (svn_path_is_backpath_present(path))
return svn_error_createf(SVN_ERR_BAD_URL, NULL,
_("URL '%s' contains a '..' element"),
path);
/* strip any trailing '/' */
path = svn_uri_canonicalize(path, pool);
}
else /* not a url, so treat as a path */
{
/* Normalize path to subversion internal style */
/* ### In Subversion < 1.6 this method on Windows actually tried
to lookup the path on disk to fix possible invalid casings in
the passed path. (An extremely expensive operation; especially
on network drives).
This 'feature'is now removed as it penalizes every correct
path passed, and also breaks behavior of e.g.
'svn status .' returns '!' file, because there is only a "File"
on disk.
But when you then call 'svn status file', you get '? File'.
As JavaHL is designed to be platform independent I assume users
don't want this broken behavior on non round-trippable paths, nor
the performance penalty.
*/
path = svn_dirent_internal_style(path, pool);
/* For kicks and giggles, let's absolutize it. */
SVN_ERR(svn_dirent_get_absolute(&path, path, pool));
}
return NULL;
}
( run in 0.520 second using v1.01-cache-2.11-cpan-5b529ec07f3 )