java/File: add non-static GetAbsolutePath() overload
This commit is contained in:
parent
285ba54fe5
commit
a237db556a
@ -54,7 +54,7 @@ Java::File::ToAbsolutePath(JNIEnv *env, jobject _file) noexcept
|
|||||||
|
|
||||||
LocalObject file(env, _file);
|
LocalObject file(env, _file);
|
||||||
|
|
||||||
const jstring path = getAbsolutePath(env, file);
|
const jstring path = GetAbsolutePath(env, file);
|
||||||
if (DiscardException(env) || path == nullptr)
|
if (DiscardException(env) || path == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#define JAVA_FILE_HXX
|
#define JAVA_FILE_HXX
|
||||||
|
|
||||||
#include "Object.hxx"
|
#include "Object.hxx"
|
||||||
|
#include "String.hxx"
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
|
||||||
@ -51,11 +52,19 @@ public:
|
|||||||
static void Initialise(JNIEnv *env) noexcept;
|
static void Initialise(JNIEnv *env) noexcept;
|
||||||
|
|
||||||
gcc_nonnull_all
|
gcc_nonnull_all
|
||||||
static jstring getAbsolutePath(JNIEnv *env, jobject file) noexcept {
|
static jstring GetAbsolutePath(JNIEnv *env, jobject file) noexcept {
|
||||||
return (jstring)env->CallObjectMethod(file,
|
return (jstring)env->CallObjectMethod(file,
|
||||||
getAbsolutePath_method);
|
getAbsolutePath_method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String GetAbsolutePath() const noexcept {
|
||||||
|
return {GetEnv(), GetAbsolutePath(GetEnv(), Get())};
|
||||||
|
}
|
||||||
|
|
||||||
|
String GetAbsolutePathChecked() const noexcept {
|
||||||
|
return *this ? GetAbsolutePath() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke File.getAbsolutePath() and release the
|
* Invoke File.getAbsolutePath() and release the
|
||||||
* specified File reference.
|
* specified File reference.
|
||||||
|
Loading…
Reference in New Issue
Block a user