Chi Hsuan Yen added the comment:
> 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
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue29176>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com