MCPcopy Create free account
hub / github.com/RenderKit/embree / ParseEXRVersionFromFile

Function ParseEXRVersionFromFile

tutorials/common/image/tinyexr.h:8909–8946  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8907}
8908
8909int ParseEXRVersionFromFile(EXRVersion *version, const char *filename) {
8910 if (filename == NULL) {
8911 return TINYEXR_ERROR_INVALID_ARGUMENT;
8912 }
8913
8914 FILE *fp = NULL;
8915#ifdef _WIN32
8916#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang.
8917 errno_t err = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb");
8918 if (err != 0) {
8919 // TODO(syoyo): return wfopen_s erro code
8920 return TINYEXR_ERROR_CANT_OPEN_FILE;
8921 }
8922#else
8923 // Unknown compiler or MinGW without MINGW_HAS_SECURE_API.
8924 fp = fopen(filename, "rb");
8925#endif
8926#else
8927 fp = fopen(filename, "rb");
8928#endif
8929 if (!fp) {
8930 return TINYEXR_ERROR_CANT_OPEN_FILE;
8931 }
8932
8933 // Try to read kEXRVersionSize bytes; if the file is shorter than
8934 // kEXRVersionSize, this will produce an error. This avoids a call to
8935 // fseek(fp, 0, SEEK_END), which is not required to be supported by C
8936 // implementations.
8937 unsigned char buf[tinyexr::kEXRVersionSize];
8938 size_t ret = fread(&buf[0], 1, tinyexr::kEXRVersionSize, fp);
8939 fclose(fp);
8940
8941 if (ret != tinyexr::kEXRVersionSize) {
8942 return TINYEXR_ERROR_INVALID_FILE;
8943 }
8944
8945 return ParseEXRVersionFromMemory(version, buf, tinyexr::kEXRVersionSize);
8946}
8947
8948int LoadEXRMultipartImageFromMemory(EXRImage *exr_images,
8949 const EXRHeader **exr_headers,

Callers 3

EXRLayersFunction · 0.85
LoadEXRWithLayerFunction · 0.85
IsEXRFunction · 0.85

Calls 3

UTF8ToWcharFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected