Return error when include file is not located

Related work item: Github #30
This commit is contained in:
Minmin Gong 2019-01-30 00:02:20 -08:00
Родитель a3ac01e7ab
Коммит 47cfbc2532
1 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -245,13 +245,16 @@ namespace
{
std::vector<char> 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());
}