mpd/src/java/File.cxx

35 lines
810 B
C++
Raw Normal View History

// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <max.kellermann@gmail.com>
#include "File.hxx"
#include "Class.hxx"
#include "String.hxx"
#include "Object.hxx"
2019-04-24 14:43:09 +02:00
#include "Exception.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/Limits.hxx"
jmethodID Java::File::getAbsolutePath_method;
void
2018-08-28 13:27:28 +02:00
Java::File::Initialise(JNIEnv *env) noexcept
{
Class cls(env, "java/io/File");
getAbsolutePath_method = env->GetMethodID(cls, "getAbsolutePath",
"()Ljava/lang/String;");
}
AllocatedPath
2018-08-28 13:27:28 +02:00
Java::File::ToAbsolutePath(JNIEnv *env, jobject _file) noexcept
{
LocalObject file(env, _file);
const jstring path = GetAbsolutePath(env, file);
2019-04-24 14:43:09 +02:00
if (DiscardException(env) || path == nullptr)
return nullptr;
Java::String path2(env, path);
return AllocatedPath::FromFS(path2.ToString());
}