misc/vim: inform the user when no results are found
[nit.git] / c_src / file_nit.c
index 2ce41d3..f6a6987 100644 (file)
  * another product.
  */
 
-#define _POSIX_C_SOURCE 1
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <string.h>
+#include <dirent.h>
+#include <poll.h>
+
+#include "file_nit.h"
 
 int string_NativeString_NativeString_file_exists_0(char *f){
        FILE *hdl = fopen(f,"r");
@@ -52,3 +55,21 @@ void *file_NativeFile_NativeFile_file_stat_0(FILE *f){
 extern int string_NativeString_NativeString_file_delete_0(char *f){
   return (remove(f) == 0);
 }
+
+int file_stdin_poll_in_(void) {
+       struct pollfd fd = {0, POLLIN, 0};
+       int res = poll(&fd, 1, 0);
+       if (res == -1) {
+               perror("Error poll stdin");
+               exit(EXIT_FAILURE);
+       }
+       return res > 0;
+}
+
+FILE* file_int_fdtostream(int fd, char* mode){
+       return fdopen(fd, mode);
+}
+
+int file_NativeFile_NativeFile_set_buffering_type_0(FILE* f, int buf_sz, int mode){
+       return setvbuf(f, NULL, mode, buf_sz);
+}