stdin_to_temp.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_STDIN_TO_TEMP_H
  9. #define IGL_STDIN_TO_TEMP_H
  10. #include "igl_inline.h"
  11. #include <cstdio>
  12. namespace igl
  13. {
  14. // Write stdin/piped input to a temporary file which can than be preprocessed as it
  15. // is (a normal file). This is often useful if you want to process stdin/piped
  16. // with library functions that expect to be able to fseek(), rewind() etc..
  17. //
  18. // If your application is not using fseek(), rewind(), etc. but just reading
  19. // from stdin then this will likely cause a bottle neck as it defeats the whole
  20. // purpose of piping.
  21. //
  22. // Outputs:
  23. // temp_file pointer to temp file pointer, rewound to beginning of file so
  24. // its ready to be read
  25. // Return true only if no errors were found
  26. //
  27. // Note: Caller is responsible for closing the file (tmpfile() automatically
  28. // unlinks the file so there is no need to remove/delete/unlink the file)
  29. IGL_INLINE bool stdin_to_temp(FILE ** temp_file);
  30. }
  31. #ifndef IGL_STATIC_LIBRARY
  32. # include "stdin_to_temp.cpp"
  33. #endif
  34. #endif