From 47cfbc25322647c05a6e70e3a89f4c5797661827 Mon Sep 17 00:00:00 2001 From: Minmin Gong Date: Wed, 30 Jan 2019 00:02:20 -0800 Subject: [PATCH] Return error when include file is not located Related work item: Github #30 --- Source/Core/ShaderConductor.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Core/ShaderConductor.cpp b/Source/Core/ShaderConductor.cpp index eb39eb2..d3de64a 100644 --- a/Source/Core/ShaderConductor.cpp +++ b/Source/Core/ShaderConductor.cpp @@ -245,13 +245,16 @@ namespace { std::vector ret; std::ifstream includeFile(includeName, std::ios_base::in); - includeFile.seekg(0, std::ios::end); - ret.resize(includeFile.tellg()); - includeFile.seekg(0, std::ios::beg); - includeFile.read(ret.data(), ret.size()); - while (!ret.empty() && (ret.back() == '\0')) + if (includeFile) { - ret.pop_back(); + includeFile.seekg(0, std::ios::end); + ret.resize(includeFile.tellg()); + includeFile.seekg(0, std::ios::beg); + includeFile.read(ret.data(), ret.size()); + while (!ret.empty() && (ret.back() == '\0')) + { + ret.pop_back(); + } } return std::string(ret.data(), ret.size()); }