commit
3081e83f43
|
@ -141,7 +141,10 @@ void FBXImporter::SetupProperties(const Importer *pImp) {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Imports the given file into the given scene structure.
|
// Imports the given file into the given scene structure.
|
||||||
void FBXImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
void FBXImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
std::unique_ptr<IOStream> stream(pIOHandler->Open(pFile, "rb"));
|
auto streamCloser = [&](IOStream *pStream) {
|
||||||
|
pIOHandler->Close(pStream);
|
||||||
|
};
|
||||||
|
std::unique_ptr<IOStream, decltype(streamCloser)> stream(pIOHandler->Open(pFile, "rb"), streamCloser);
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
ThrowException("Could not open file for reading");
|
ThrowException("Could not open file for reading");
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,10 @@ const aiImporterDesc *ObjFileImporter::GetInfo() const {
|
||||||
void ObjFileImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSystem *pIOHandler) {
|
void ObjFileImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSystem *pIOHandler) {
|
||||||
// Read file into memory
|
// Read file into memory
|
||||||
static const std::string mode = "rb";
|
static const std::string mode = "rb";
|
||||||
std::unique_ptr<IOStream> fileStream(pIOHandler->Open(file, mode));
|
auto streamCloser = [&](IOStream *pStream) {
|
||||||
|
pIOHandler->Close(pStream);
|
||||||
|
};
|
||||||
|
std::unique_ptr<IOStream, decltype(streamCloser)> fileStream(pIOHandler->Open(file, mode), streamCloser);
|
||||||
if (!fileStream.get()) {
|
if (!fileStream.get()) {
|
||||||
throw DeadlyImportError("Failed to open file " + file + ".");
|
throw DeadlyImportError("Failed to open file " + file + ".");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue