MCPcopy Create free account
hub / github.com/OpenPathGuidingLibrary/openpgl / ParseEXRVersionFromFile

Function ParseEXRVersionFromFile

third-party/tinyexr/tinyexr.h:8820–8857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8818}
8819
8820int ParseEXRVersionFromFile(EXRVersion *version, const char *filename) {
8821 if (filename == NULL) {
8822 return TINYEXR_ERROR_INVALID_ARGUMENT;
8823 }
8824
8825 FILE *fp = NULL;
8826#ifdef _WIN32
8827#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) // MSVC, MinGW GCC, or Clang.
8828 errno_t err = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb");
8829 if (err != 0) {
8830 // TODO(syoyo): return wfopen_s erro code
8831 return TINYEXR_ERROR_CANT_OPEN_FILE;
8832 }
8833#else
8834 // Unknown compiler or MinGW without MINGW_HAS_SECURE_API.
8835 fp = fopen(filename, "rb");
8836#endif
8837#else
8838 fp = fopen(filename, "rb");
8839#endif
8840 if (!fp) {
8841 return TINYEXR_ERROR_CANT_OPEN_FILE;
8842 }
8843
8844 // Try to read kEXRVersionSize bytes; if the file is shorter than
8845 // kEXRVersionSize, this will produce an error. This avoids a call to
8846 // fseek(fp, 0, SEEK_END), which is not required to be supported by C
8847 // implementations.
8848 unsigned char buf[tinyexr::kEXRVersionSize];
8849 size_t ret = fread(&buf[0], 1, tinyexr::kEXRVersionSize, fp);
8850 fclose(fp);
8851
8852 if (ret != tinyexr::kEXRVersionSize) {
8853 return TINYEXR_ERROR_INVALID_FILE;
8854 }
8855
8856 return ParseEXRVersionFromMemory(version, buf, tinyexr::kEXRVersionSize);
8857}
8858
8859int LoadEXRMultipartImageFromMemory(EXRImage *exr_images,
8860 const EXRHeader **exr_headers,

Callers 4

EXRLayersFunction · 0.85
LoadEXRWithLayerFunction · 0.85
IsEXRFunction · 0.85

Calls 2

UTF8ToWcharFunction · 0.85

Tested by

no test coverage detected