mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-05 02:29:24 +02:00
Initial commit 🌱
This commit is contained in:
commit
b1a00a03d2
2659 changed files with 184218 additions and 0 deletions
31
jni/utils/org_thoughtcrime_securesms_util_FileUtils.cpp
Normal file
31
jni/utils/org_thoughtcrime_securesms_util_FileUtils.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "org_thoughtcrime_securesms_util_FileUtils.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue