1234567891011121314151617181920212223242526272829303132333435363738 |
- #include "stdin_to_temp.h"
- #include <iostream>
- IGL_INLINE bool igl::stdin_to_temp(FILE ** temp_file)
- {
-
- *temp_file = tmpfile();
- if(*temp_file == NULL)
- {
- fprintf(stderr,"IOError: temp file could not be created.\n");
- return false;
- }
- char c;
-
- while (std::cin.good())
- {
- c = std::cin.get();
- if(std::cin.good())
- {
- if(1 != fwrite(&c,sizeof(char),1,*temp_file))
- {
- fprintf(stderr,"IOError: error writing to tempfile.\n");
- return false;
- }
- }
- }
-
- rewind(*temp_file);
- return true;
- }
|