Message288348
> Is tmpfile() available on Android?
Yes. Just tried it with Android NDK r13 with clang and API 21 (Android 5.0). Here's the source code test.c:
#include <stdio.h>
int main()
{
FILE *fp = NULL;
char c = '\0';
fp = tmpfile();
fprintf(fp, "123\n");
scanf("%c", &c);
fclose(fp);
return 0;
}
Compilation command:
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target aarch64-none-android-linux -gcc-toolchain /opt/android-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 --sysroot /opt/android-ndk/platforms/android-21/arch-arm64/usr -pie test.c
(didn't test gcc as it's declared as 'deprecated' in NDK)
Before scanf() returns, the temporary file is already deleted:
shell@ASUS_Z00E_2:/ $ ls -l /proc/19300/fd
lrwx------ shell shell 2017-02-22 15:21 0 -> /dev/pts/0
lrwx------ shell shell 2017-02-22 15:21 1 -> /dev/pts/0
lrwx------ shell shell 2017-02-22 15:21 2 -> /dev/pts/0
lrwx------ shell shell 2017-02-22 15:20 3 -> /data/local/tmp/tmp.VguNf9sqcW (deleted)
lr-x------ shell shell 2017-02-22 15:21 9 -> /dev/__properties__
For interested, here's its implementation: https://android.googlesource.com/platform/bionic/+/android-5.0.0_r1/libc/bionic/tmpfile.cpp |
|
Date |
User |
Action |
Args |
2017-02-22 10:06:02 | yan12125 | set | recipients:
+ yan12125, twouters, vstinner, christian.heimes, xdegaye, serhiy.storchaka |
2017-02-22 10:06:02 | yan12125 | set | messageid: <1487757962.39.0.441121421384.issue29176@psf.upfronthosting.co.za> |
2017-02-22 10:06:02 | yan12125 | link | issue29176 messages |
2017-02-22 10:06:02 | yan12125 | create | |
|