Skip to content

Commit

Permalink
Fix gcc warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Jan 28, 2021
1 parent 92af1b4 commit e692908
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions CesiumGltfReader/test/TestReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,26 @@ using namespace CesiumGltf;
namespace {
std::vector<uint8_t> readFile(const std::string& path) {
FILE* fp = std::fopen(path.c_str(), "rb");
if (!fp) {
return {};
}
REQUIRE(fp);

std::fseek(fp, 0, SEEK_END);
long pos = std::ftell(fp);
std::fseek(fp, 0, SEEK_SET);
try {
std::fseek(fp, 0, SEEK_END);
long pos = std::ftell(fp);
std::fseek(fp, 0, SEEK_SET);

std::vector<uint8_t> result(static_cast<size_t>(pos));
std::fread(result.data(), 1, result.size(), fp);
std::vector<uint8_t> result(static_cast<size_t>(pos));
size_t itemsRead = std::fread(result.data(), 1, result.size(), fp);
REQUIRE(itemsRead == result.size());

std::fclose(fp);
std::fclose(fp);

return result;
return result;
} catch(...) {
if (fp) {
std::fclose(fp);
}
throw;
}
}
}

Expand Down

0 comments on commit e692908

Please sign in to comment.