MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / ParseEXRVersionFromFile

Function ParseEXRVersionFromFile

Source/ThirdParty/tinyexr.h:10462–10499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10460}
10461
10462int ParseEXRVersionFromFile(EXRVersion *version, const char *filename) {
10463 if (filename == NULL) {
10464 return TINYEXR_ERROR_INVALID_ARGUMENT;
10465 }
10466
10467 FILE *fp = NULL;
10468#ifdef _WIN32
10469#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang.
10470 errno_t err = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb");
10471 if (err != 0) {
10472 // TODO(syoyo): return wfopen_s erro code
10473 return TINYEXR_ERROR_CANT_OPEN_FILE;
10474 }
10475#else
10476 // Unknown compiler or MinGW without MINGW_HAS_SECURE_API.
10477 fp = fopen(filename, "rb");
10478#endif
10479#else
10480 fp = fopen(filename, "rb");
10481#endif
10482 if (!fp) {
10483 return TINYEXR_ERROR_CANT_OPEN_FILE;
10484 }
10485
10486 // Try to read kEXRVersionSize bytes; if the file is shorter than
10487 // kEXRVersionSize, this will produce an error. This avoids a call to
10488 // fseek(fp, 0, SEEK_END), which is not required to be supported by C
10489 // implementations.
10490 unsigned char buf[tinyexr::kEXRVersionSize];
10491 size_t ret = fread(&buf[0], 1, tinyexr::kEXRVersionSize, fp);
10492 fclose(fp);
10493
10494 if (ret != tinyexr::kEXRVersionSize) {
10495 return TINYEXR_ERROR_INVALID_FILE;
10496 }
10497
10498 return ParseEXRVersionFromMemory(version, buf, tinyexr::kEXRVersionSize);
10499}
10500
10501int LoadEXRMultipartImageFromMemory(EXRImage *exr_images,
10502 const EXRHeader **exr_headers,

Callers 4

EXRLayersFunction · 0.85
LoadEXRWithLayerFunction · 0.85
IsEXRFunction · 0.85
IsSpectralEXRFunction · 0.85

Calls 2

UTF8ToWcharFunction · 0.85

Tested by

no test coverage detected