From 9a50b295817337915efe597ba9759bc6cfff5c90 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 3 Oct 2017 18:44:23 +0200 Subject: [PATCH] ResourceFile: error handling... --- ResourceFiles/ResourceFile.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ResourceFiles/ResourceFile.cc b/ResourceFiles/ResourceFile.cc index ba9b332ed8..7021566ee1 100644 --- a/ResourceFiles/ResourceFile.cc +++ b/ResourceFiles/ResourceFile.cc @@ -217,11 +217,14 @@ bool ResourceFile::read() case Format::basilisk: { fs::ifstream dataIn(path); + if(!dataIn) + return false; data = std::string(std::istreambuf_iterator(dataIn), std::istreambuf_iterator()); fs::ifstream rsrcIn(path.parent_path() / ".rsrc" / path.filename()); - resources = Resources(rsrcIn); + if(rsrcIn) + resources = Resources(rsrcIn); fs::ifstream finfIn(path.parent_path() / ".finf" / path.filename()); if(finfIn) { @@ -234,10 +237,13 @@ bool ResourceFile::read() case Format::real: { fs::ifstream dataIn(path); + if(!dataIn) + return false; data = std::string(std::istreambuf_iterator(dataIn), std::istreambuf_iterator()); fs::ifstream rsrcIn(path / "..namedfork" / "rsrc"); - resources = Resources(rsrcIn); + if(rsrcIn) + resources = Resources(rsrcIn); char finf[32]; int n = getxattr(path.c_str(), XATTR_FINDERINFO_NAME,