MCPcopy Create free account
hub / github.com/cinder/Cinder / ParseEXRVersionFromFile

Function ParseEXRVersionFromFile

include/tinyexr/tinyexr.h:8904–8941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 4

EXRLayersFunction · 0.85
LoadEXRWithLayerFunction · 0.85
IsEXRFunction · 0.85

Calls 3

UTF8ToWcharFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected