stdin_to_temp.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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. /// @param[out] temp_file pointer to temp file pointer, rewound to beginning
  23. /// of file so its ready to be read
  24. /// @return true only if no errors were found
  25. ///
  26. /// \note caller is responsible for closing the file (tmpfile() automatically
  27. /// unlinks the file so there is no need to remove/delete/unlink the file)
  28. IGL_INLINE bool stdin_to_temp(FILE ** temp_file);
  29. }
  30. #ifndef IGL_STATIC_LIBRARY
  31. # include "stdin_to_temp.cpp"
  32. #endif
  33. #endif