c_src : Regenerated c_src to prevent use of String contructors
[nit.git] / c_src / file_nit.c
index 02b725e..ca02ba1 100644 (file)
 #include <sys/types.h>
 #include <string.h>
 #include <dirent.h>
+#include <poll.h>
 
 #include "file_nit.h"
 
-
+#ifndef NONITCNI
 /*
 C implementation of file::String::files
 
 Imported methods signatures:
        HashSet new_HashSet(  ) for hash_collection::HashSet::init
        void HashSet_add( HashSet recv, Object item ) for hash_collection::HashSet::(abstract_collection::SimpleCollection::add)
-       String new_String_from_cstring( char * str ) for string::String::from_cstring
+       String NativeString_to_s() for string::NativeString::to_s
        int HashSet_is_a_Set( HashSet value ) to check if a HashSet[String] is a Set[String]
        Set HashSet_as_Set( HashSet value ) to cast from HashSet[String] to Set[String]
 */
@@ -57,7 +58,7 @@ Set String_files___impl( String recv )
                        if ( strcmp( de->d_name, ".." ) != 0 &&
                                strcmp( de->d_name, "." ) != 0 )
                        {
-                               file_name = new_String_from_cstring( strdup( de->d_name ) );
+                               file_name = NativeString_to_s( strdup( de->d_name ) );
                                HashSet_add( results, String_as_Object( file_name ) );
                        }
 
@@ -65,6 +66,7 @@ Set String_files___impl( String recv )
                return HashSet_as_Set( results );
        }
 }
+#endif
 
 int string_NativeString_NativeString_file_exists_0(char *f){
        FILE *hdl = fopen(f,"r");
@@ -97,3 +99,13 @@ 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;
+}