read_file_binary.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2020 Jérémie Dumas <[email protected]>
  4. // Copyright (C) 2021 Alec Jacobson <[email protected]>
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla Public License
  7. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  8. // obtain one at http://mozilla.org/MPL/2.0/.
  9. #ifndef IGL_READ_FILE_BINARY_H
  10. #define IGL_READ_FILE_BINARY_H
  11. #include "igl_inline.h"
  12. #include <cstdint>
  13. #include <streambuf>
  14. #include <istream>
  15. #include <string>
  16. #include <vector>
  17. namespace igl {
  18. /// Read contents of file into a buffer of uint8_t bytes.
  19. ///
  20. /// @param[in,out] fp pointer to open File
  21. /// @param[out] fileBufferBytes contents of file as vector of bytes
  22. ///
  23. /// #### Side effects:
  24. /// closes fp
  25. /// \throws runtime_error on error
  26. IGL_INLINE void read_file_binary(
  27. FILE *fp,
  28. std::vector<uint8_t> &fileBufferBytes);
  29. }
  30. #ifndef IGL_STATIC_LIBRARY
  31. #include "read_file_binary.cpp"
  32. #endif
  33. #endif