1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-22 20:35:44 +01:00

Fixed text back-end in Python

This commit is contained in:
Anthony Scemama 2023-04-12 14:59:20 +02:00
parent bd58998d04
commit d9a15c12d3

View File

@ -162,6 +162,29 @@ trexio_text_inquire (const char* file_name)
}
#+end_src
On non-POSIX file systems, the function ~mkdtemp~ might is not defined.
In that case, we define an alternate one, which is not as safe as the original one.
#+begin_src c :tangle basic_text.c
#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L
#else
char* mkdtemp(char* template) {
char* dir = NULL;
dir = tmpnam(dir);
if (dir == NULL) return NULL;
if (mkdir(dir, S_IRWXU | S_IRWXG | S_IRWXO) != 0) {
return NULL;
}
strcpy(template, dir);
return template;
}
#endif
#+end_src
#+begin_src c :tangle basic_text.c
trexio_exit_code
trexio_text_init (trexio_t* const file)