mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-12-23 12:56:53 +01:00
Merge branch 'TREX-CoE:master' into master
This commit is contained in:
commit
8e2ba3a5b4
@ -145,10 +145,10 @@ trexio_text_inquire (const char* file_name)
|
|||||||
if (file_exists) {
|
if (file_exists) {
|
||||||
|
|
||||||
bool is_a_directory = false;
|
bool is_a_directory = false;
|
||||||
#ifdef S_IFDIR
|
#if defined(S_IFDIR)
|
||||||
is_a_directory = st.st_mode & S_IFDIR;
|
is_a_directory = st.st_mode & S_IFDIR;
|
||||||
#elif S_ISDIR
|
#elif defined(S_ISDIR)
|
||||||
is_a_directory = S_ISDIR(s.st_mode);
|
is_a_directory = S_ISDIR(st.st_mode);
|
||||||
#else
|
#else
|
||||||
printf("Some important macros are missing for directory handling.\n");
|
printf("Some important macros are missing for directory handling.\n");
|
||||||
return TREXIO_FAILURE;
|
return TREXIO_FAILURE;
|
||||||
@ -162,6 +162,29 @@ trexio_text_inquire (const char* file_name)
|
|||||||
}
|
}
|
||||||
#+end_src
|
#+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
|
#+begin_src c :tangle basic_text.c
|
||||||
trexio_exit_code
|
trexio_exit_code
|
||||||
trexio_text_init (trexio_t* const file)
|
trexio_text_init (trexio_t* const file)
|
||||||
|
Loading…
Reference in New Issue
Block a user