fs: handle filesystem_error in directory_archive::load()
we were hitting this on CI when attempting to load a texture called "light"; file_size() was throwing because it was attempting to get the file size of a directory called "light".
This commit is contained in:
parent
23e98c0e94
commit
837524999b
15
common/fs.cc
15
common/fs.cc
|
|
@ -48,11 +48,16 @@ struct directory_archive : archive_like
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
uintmax_t size = file_size(p);
|
||||
std::ifstream stream(p, std::ios_base::in | std::ios_base::binary);
|
||||
std::vector<uint8_t> data(size);
|
||||
stream.read(reinterpret_cast<char *>(data.data()), size);
|
||||
return data;
|
||||
try {
|
||||
uintmax_t size = file_size(p);
|
||||
std::ifstream stream(p, std::ios_base::in | std::ios_base::binary);
|
||||
std::vector<uint8_t> data(size);
|
||||
stream.read(reinterpret_cast<char *>(data.data()), size);
|
||||
return data;
|
||||
} catch (const filesystem_error &e) {
|
||||
logging::funcprint("WARNING: {}\n", e.what());
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue