* @memberof ktxTexture1 @private * @brief Construct a ktxTexture1 from a named KTX file. * * The file name must be encoded in utf-8. On Windows convert unicode names * to utf-8 with @c WideCharToMultiByte(CP_UTF8, ...) before calling. * * See ktxTextureInt_constructFromStream for details. * * @param[in] This pointer to a ktxTextureInt-sized block of memory to * initialize.
| 479 | * For other exceptions, see ktxTexture_constructFromStream(). |
| 480 | */ |
| 481 | static KTX_error_code |
| 482 | ktxTexture1_constructFromNamedFile(ktxTexture1* This, |
| 483 | const char* const filename, |
| 484 | ktxTextureCreateFlags createFlags) |
| 485 | { |
| 486 | FILE* file; |
| 487 | ktxStream stream; |
| 488 | KTX_error_code result; |
| 489 | |
| 490 | if (This == NULL || filename == NULL) |
| 491 | return KTX_INVALID_VALUE; |
| 492 | |
| 493 | file = ktxFOpenUTF8(filename, "rb"); |
| 494 | if (!file) |
| 495 | return KTX_FILE_OPEN_FAILED; |
| 496 | |
| 497 | result = ktxFileStream_construct(&stream, file, KTX_TRUE); |
| 498 | if (result == KTX_SUCCESS) |
| 499 | result = ktxTexture1_constructFromStream(This, &stream, createFlags); |
| 500 | |
| 501 | return result; |
| 502 | } |
| 503 | |
| 504 | /** |
| 505 | * @memberof ktxTexture1 @private |
no test coverage detected