51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
#include "SysInfo.hpp"
|
|
|
|
#if defined(__APPLE__) && !defined(__IPHONEOS__)
|
|
#include <CoreServices/CoreServices.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
|
|
SysInfo sysinfo;
|
|
|
|
SysInfo::SysInfo() {
|
|
density_dpi = 0;
|
|
xdpi = 0.0f;
|
|
ydpi = 0.0f;
|
|
#if defined(__APPLE__) && !defined(__IPHONEOS__)
|
|
FSRef ref;
|
|
OSType folderType = kApplicationSupportFolderType;
|
|
char path[PATH_MAX];
|
|
FSFindFolder(kUserDomain, folderType, kCreateFolder, &ref);
|
|
FSRefMakePath(&ref, (UInt8*)&path, PATH_MAX);
|
|
char path_dir[PATH_MAX];
|
|
snprintf(path_dir, PATH_MAX, "%s/RtB", path);
|
|
user_dir.assign(path_dir);
|
|
#endif
|
|
}
|
|
SysInfo::~SysInfo() {
|
|
}
|
|
|
|
#ifdef __ANDROID__
|
|
JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setDpiInfo(JNIEnv* env, jobject obj, jint density_dpi, jfloat xdpi, jfloat ydpi) {
|
|
sysinfo.density_dpi = density_dpi;
|
|
sysinfo.xdpi = xdpi;
|
|
sysinfo.ydpi = ydpi;
|
|
}
|
|
JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setAppDirectory(JNIEnv* env, jobject obj, jstring app_dir) {
|
|
jboolean iscopy;
|
|
const char *native_string = env->GetStringUTFChars(app_dir, &iscopy);
|
|
sysinfo.app_dir.assign(native_string);
|
|
env->ReleaseStringUTFChars(app_dir, native_string);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setExtDirectory(JNIEnv* env, jobject obj, jstring ext_dir) {
|
|
jboolean iscopy;
|
|
const char *native_string = env->GetStringUTFChars(ext_dir, &iscopy);
|
|
sysinfo.ext_dir.assign(native_string);
|
|
env->ReleaseStringUTFChars(ext_dir, native_string);
|
|
}
|
|
|
|
#endif
|