stdin_to_temp.h 1008 B

1234567891011121314151617181920212223242526272829
  1. #ifndef IGL_STDIN_TO_TEMP_H
  2. #define IGL_STDIN_TO_TEMP_H
  3. #include "igl_inline.h"
  4. #include <cstdio>
  5. namespace igl
  6. {
  7. // Write stdin/piped input to a temporary file which can than be preprocessed as it
  8. // is (a normal file). This is often useful if you want to process stdin/piped
  9. // with library functions that expect to be able to fseek(), rewind() etc..
  10. //
  11. // If your application is not using fseek(), rewind(), etc. but just reading
  12. // from stdin then this will likely cause a bottle neck as it defeats the whole
  13. // purpose of piping.
  14. //
  15. // Outputs:
  16. // temp_file pointer to temp file pointer, rewound to beginning of file so
  17. // its ready to be read
  18. // Return true only if no errors were found
  19. //
  20. // Note: Caller is responsible for closing the file (tmpfile() automatically
  21. // unlinks the file so there is no need to remove/delete/unlink the file)
  22. IGL_INLINE bool stdin_to_temp(FILE ** temp_file);
  23. }
  24. #ifdef IGL_HEADER_ONLY
  25. # include "stdin_to_temp.cpp"
  26. #endif
  27. #endif