// android.system.Os has no public chdir() (confirmed against the actual
// API 34 stub jar - Java has no way to change a process's working
// directory at all). This is the one bit of native code QuestShockActivity
// needs, compiled into the same "main" library as engine/ (see
// android/engine-patches/01-android-shared-lib.patch's ANDROID_EXTRA_SOURCES)
// - engine/ itself is never modified.
#include <jni.h>
#include <unistd.h>

JNIEXPORT void JNICALL
Java_de_ladkau_questshock_QuestShockActivity_nativeChdir(JNIEnv *env, jclass clazz, jstring path) {
    const char *cpath = (*env)->GetStringUTFChars(env, path, NULL);
    chdir(cpath);
    (*env)->ReleaseStringUTFChars(env, path, cpath);
}
