mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-26 05:58:33 +00:00
Move all files to natural position.
This commit is contained in:
45
app/jni/utils/org_thoughtcrime_securesms_util_FileUtils.cpp
Normal file
45
app/jni/utils/org_thoughtcrime_securesms_util_FileUtils.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "org_thoughtcrime_securesms_util_FileUtils.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/memfd.h>
|
||||
#include <syscall.h>
|
||||
|
||||
jint JNICALL Java_org_thoughtcrime_securesms_util_FileUtils_getFileDescriptorOwner
|
||||
(JNIEnv *env, jclass clazz, jobject fileDescriptor)
|
||||
{
|
||||
jclass fdClass = env->GetObjectClass(fileDescriptor);
|
||||
|
||||
if (fdClass == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
jfieldID fdFieldId = env->GetFieldID(fdClass, "descriptor", "I");
|
||||
|
||||
if (fdFieldId == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fd = env->GetIntField(fileDescriptor, fdFieldId);
|
||||
|
||||
struct stat stat_struct;
|
||||
|
||||
if (fstat(fd, &stat_struct) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return stat_struct.st_uid;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_thoughtcrime_securesms_util_FileUtils_createMemoryFileDescriptor
|
||||
(JNIEnv *env, jclass clazz, jstring jname)
|
||||
{
|
||||
const char *name = env->GetStringUTFChars(jname, NULL);
|
||||
|
||||
int fd = syscall(SYS_memfd_create, name, MFD_CLOEXEC);
|
||||
|
||||
env->ReleaseStringUTFChars(jname, name);
|
||||
|
||||
return fd;
|
||||
}
|
29
app/jni/utils/org_thoughtcrime_securesms_util_FileUtils.h
Normal file
29
app/jni/utils/org_thoughtcrime_securesms_util_FileUtils.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_thoughtcrime_securesms_util_FileUtils */
|
||||
|
||||
#ifndef _Included_org_thoughtcrime_securesms_util_FileUtils
|
||||
#define _Included_org_thoughtcrime_securesms_util_FileUtils
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_thoughtcrime_securesms_util_FileUtils
|
||||
* Method: getFileDescriptorOwner
|
||||
* Signature: (Ljava/io/FileDescriptor;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_thoughtcrime_securesms_util_FileUtils_getFileDescriptorOwner
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_thoughtcrime_securesms_util_FileUtils
|
||||
* Method: createMemoryFileDescriptor
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_thoughtcrime_securesms_util_FileUtils_createMemoryFileDescriptor
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
Reference in New Issue
Block a user