ResourceFile: error handling...

This commit is contained in:
Wolfgang Thaller 2017-10-03 18:44:23 +02:00
parent 687fd2a779
commit 9a50b29581

View File

@ -217,11 +217,14 @@ bool ResourceFile::read()
case Format::basilisk: case Format::basilisk:
{ {
fs::ifstream dataIn(path); fs::ifstream dataIn(path);
if(!dataIn)
return false;
data = std::string(std::istreambuf_iterator<char>(dataIn), data = std::string(std::istreambuf_iterator<char>(dataIn),
std::istreambuf_iterator<char>()); std::istreambuf_iterator<char>());
fs::ifstream rsrcIn(path.parent_path() / ".rsrc" / path.filename()); 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()); fs::ifstream finfIn(path.parent_path() / ".finf" / path.filename());
if(finfIn) if(finfIn)
{ {
@ -234,10 +237,13 @@ bool ResourceFile::read()
case Format::real: case Format::real:
{ {
fs::ifstream dataIn(path); fs::ifstream dataIn(path);
if(!dataIn)
return false;
data = std::string(std::istreambuf_iterator<char>(dataIn), data = std::string(std::istreambuf_iterator<char>(dataIn),
std::istreambuf_iterator<char>()); std::istreambuf_iterator<char>());
fs::ifstream rsrcIn(path / "..namedfork" / "rsrc"); fs::ifstream rsrcIn(path / "..namedfork" / "rsrc");
resources = Resources(rsrcIn); if(rsrcIn)
resources = Resources(rsrcIn);
char finf[32]; char finf[32];
int n = getxattr(path.c_str(), XATTR_FINDERINFO_NAME, int n = getxattr(path.c_str(), XATTR_FINDERINFO_NAME,