diff options
author | Max Kellermann <max.kellermann@gmail.com> | 2021-03-28 13:15:24 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2021-04-06 13:35:59 +0200 |
commit | a237db556ae3425957581d2139b7718d4d4f53cf (patch) | |
tree | d7dc3010453ddecb19bbf310c0310afa8afc909d /src/java | |
parent | 285ba54fe58e630c150deb1cb216fde41738b695 (diff) |
java/File: add non-static GetAbsolutePath() overload
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/File.cxx | 2 | ||||
-rw-r--r-- | src/java/File.hxx | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/java/File.cxx b/src/java/File.cxx index 0d8c789f3..4866953e3 100644 --- a/src/java/File.cxx +++ b/src/java/File.cxx @@ -54,7 +54,7 @@ Java::File::ToAbsolutePath(JNIEnv *env, jobject _file) noexcept LocalObject file(env, _file); - const jstring path = getAbsolutePath(env, file); + const jstring path = GetAbsolutePath(env, file); if (DiscardException(env) || path == nullptr) return nullptr; diff --git a/src/java/File.hxx b/src/java/File.hxx index e7a1a5363..b49cd30b8 100644 --- a/src/java/File.hxx +++ b/src/java/File.hxx @@ -31,6 +31,7 @@ #define JAVA_FILE_HXX #include "Object.hxx" +#include "String.hxx" #include <jni.h> @@ -51,11 +52,19 @@ public: static void Initialise(JNIEnv *env) noexcept; gcc_nonnull_all - static jstring getAbsolutePath(JNIEnv *env, jobject file) noexcept { + static jstring GetAbsolutePath(JNIEnv *env, jobject file) noexcept { return (jstring)env->CallObjectMethod(file, 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 * specified File reference. |