Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/javahl/native/File.cpp view on Meta::CPAN
: stringHolder(NULL)
{
m_jthis = jthis;
}
File::~File()
{
// The m_jthis does not need to be destroyed, because it is the
// passed in parameter to the Java method.
delete stringHolder;
}
/**
* Create an absolute path from the File object and return it.
* @return the input stream
*/
const char *File::getAbsPath()
{
if (stringHolder == NULL)
{
if (m_jthis == NULL)
return NULL;
JNIEnv *env = JNIUtil::getEnv();
jclass clazz = env->FindClass("java/io/File");
if (JNIUtil::isJavaExceptionThrown())
return NULL;
static jmethodID mid = 0;
if (mid == 0)
{
mid = env->GetMethodID(clazz, "getAbsolutePath",
"()Ljava/lang/String;");
if (JNIUtil::isJavaExceptionThrown())
return NULL;
}
jstring jabsolutePath = (jstring) env->CallObjectMethod(m_jthis, mid);
if (JNIUtil::isJavaExceptionThrown())
return NULL;
stringHolder = new JNIStringHolder(jabsolutePath);
/* We don't remove the local ref for jabsolutePath here, because
JNIStringHolder expects that ref to be valid for the life of
the object, which in this case is allocated on the stack.
So we just "leak" the reference, and it will get cleaned up when
we eventually exit back to Java-land. */
env->DeleteLocalRef(clazz);
}
return static_cast<const char *>(*stringHolder);
}
const char *File::getInternalStyle(const SVN::Pool &requestPool)
{
const char *path = getAbsPath();
if (path)
return svn_dirent_internal_style(path, requestPool.getPool());
else
return NULL;
}
bool File::isNull() const
{
return m_jthis == NULL;
}
( run in 0.643 second using v1.01-cache-2.11-cpan-39bf76dae61 )