History

Add tmpfile() Android implementation

Andriy Kunitsyn committed 5 years ago

Commit 8adc8f21 parent 427ed663 files · +145 −0Browse files

Showing the changes to src/core/chuck_parse.cpp (1 of 3 files). Show all

Unified · Split

src/core/chuck_parse.cpp+21−0
@@ -94,6 +94,23 @@ FILE *win32_tmpfile() · 93 unmodified lines
9494
9595
9696
97+//-----------------------------------------------------------------------------
98+// name: android_tmpfile()
99+// desc: replacement for broken tmpfile() on Android
100+//-----------------------------------------------------------------------------
101+#ifdef __ANDROID__
102+
103+#include "chuck_android.h"
104+
105+FILE *android_tmpfile()
106+{
107+ return ChuckAndroid::getTemporaryFile();
108+}
109+
110+#endif
111+
112+
113+
97114 //-----------------------------------------------------------------------------
98115 // name: chuck_parse()
99116 // desc: ...
@@ -118,9 +135,13 @@ t_CKBOOL chuck_parse( c_constr fname, FILE * fd, c_constr code ) · 18 unmodified lines
118135 // generate temp file
119136 #ifdef __PLATFORM_WIN32__
120137 fd = win32_tmpfile();
138+#elif defined (__ANDROID__)
139+ fd = android_tmpfile();
121140 #else
122141 fd = tmpfile();
123142 #endif
143+ // on some systems, tmpfile() can return NULL
144+ if( !fd ) { EM_error2( 0, "unable to create temp file" ); return FALSE; }
124145 // flag it to close
125146 clo = TRUE;
126147 // write

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t