Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/javahl/native/JNIUtil.cpp view on Meta::CPAN
"svnjavahl");
return FALSE;
}
/* Create our top-level pool. */
g_pool = svn_pool_create(NULL);
apr_allocator_t* allocator = apr_pool_allocator_get(g_pool);
if (allocator)
{
/* Keep a maximum of 1 free block, to release memory back to the JVM
(and other modules). */
apr_allocator_max_free_set(allocator, 1);
}
svn_utf_initialize2(FALSE, g_pool); /* Optimize character conversions */
svn_fs_initialize(g_pool); /* Avoid some theoretical issues */
svn_ra_initialize(g_pool);
/* We shouldn't fill the JVMs memory with FS cache data unless explictly
requested. */
{
svn_cache_config_t settings = *svn_cache_config_get();
settings.cache_size = 0;
settings.file_handle_count = 0;
settings.single_threaded = FALSE;
svn_cache_config_set(&settings);
}
#ifdef ENABLE_NLS
#ifdef WIN32
{
WCHAR ucs2_path[MAX_PATH];
char *utf8_path;
const char *internal_path;
apr_pool_t *pool;
apr_status_t apr_err;
apr_size_t inwords, outbytes;
unsigned int outlength;
pool = svn_pool_create(g_pool);
/* get dll name - our locale info will be in '../share/locale' */
inwords = sizeof(ucs2_path) / sizeof(ucs2_path[0]);
HINSTANCE moduleHandle = GetModuleHandle("libsvnjavahl-1");
GetModuleFileNameW(moduleHandle, ucs2_path, inwords);
inwords = lstrlenW(ucs2_path);
outbytes = outlength = 3 * (inwords + 1);
utf8_path = reinterpret_cast<char *>(apr_palloc(pool, outlength));
apr_err = apr_conv_ucs2_to_utf8((const apr_wchar_t *) ucs2_path,
&inwords, utf8_path, &outbytes);
if (!apr_err && (inwords > 0 || outbytes == 0))
apr_err = APR_INCOMPLETE;
if (apr_err)
{
if (stderr)
fprintf(stderr, "Can't convert module path to UTF-8");
return FALSE;
}
utf8_path[outlength - outbytes] = '\0';
internal_path = svn_dirent_internal_style(utf8_path, pool);
/* get base path name */
internal_path = svn_dirent_dirname(internal_path, pool);
internal_path = svn_dirent_join(internal_path, SVN_LOCALE_RELATIVE_PATH,
pool);
bindtextdomain(PACKAGE_NAME, internal_path);
svn_pool_destroy(pool);
}
#else
bindtextdomain(PACKAGE_NAME, SVN_LOCALE_DIR);
#endif
#endif
#if defined(WIN32) || defined(__CYGWIN__)
/* See http://svn.apache.org/repos/asf/subversion/trunk/notes/asp-dot-net-hack.txt */
/* ### This code really only needs to be invoked by consumers of
### the libsvn_wc library, which basically means SVNClient. */
if (getenv("SVN_ASP_DOT_NET_HACK"))
{
err = svn_wc_set_adm_dir("_svn", g_pool);
if (err)
{
if (stderr)
{
fprintf(stderr,
"%s: error: SVN_ASP_DOT_NET_HACK failed: %s\n",
"svnjavahl", err->message);
}
svn_error_clear(err);
return FALSE;
}
}
#endif
svn_error_set_malfunction_handler(svn_error_raise_on_malfunction);
// Build all mutexes.
g_finalizedObjectsMutex = new JNIMutex(g_pool);
if (isExceptionThrown())
return false;
g_logMutex = new JNIMutex(g_pool);
if (isExceptionThrown())
return false;
// initialized the thread local storage
if (!JNIThreadData::initThreadData())
return false;
setEnv(env);
if (isExceptionThrown())
return false;
g_initEnv = NULL;
g_inInit = false;
return true;
}
/**
* Returns the global (not request specific) pool.
* @return global pool
src/subversion/subversion/bindings/javahl/native/JNIUtil.cpp view on Meta::CPAN
}
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 1.196 second using v1.01-cache-2.11-cpan-39bf76dae61 )