mirror of https://github.com/YosysHQ/icestorm.git
icemulti: Add missing error checks
This commit is contained in:
parent
450306dfb1
commit
e9e49bb5db
|
|
@ -87,19 +87,28 @@ class Image {
|
|||
uint32_t offs;
|
||||
|
||||
public:
|
||||
Image(const char *filename) : filename(filename), ifs(filename, std::ifstream::binary) {}
|
||||
|
||||
Image(const char *filename);
|
||||
size_t size();
|
||||
void write(std::ostream &ofs, uint32_t &file_offset);
|
||||
void place(uint32_t o) { offs = o; }
|
||||
uint32_t offset() const { return offs; }
|
||||
};
|
||||
|
||||
Image::Image(const char *filename) : filename(filename), ifs(filename, std::ifstream::binary)
|
||||
{
|
||||
if (ifs.fail())
|
||||
error("can't open input image `%s': %s\n", filename, strerror(errno));
|
||||
}
|
||||
|
||||
size_t Image::size()
|
||||
{
|
||||
ifs.seekg (0, ifs.end);
|
||||
if (ifs.fail())
|
||||
error("can't seek on input image `%s': %s\n", filename, strerror(errno));
|
||||
size_t length = ifs.tellg();
|
||||
ifs.seekg (0, ifs.beg);
|
||||
if (ifs.fail())
|
||||
error("can't seek on input image `%s': %s\n", filename, strerror(errno));
|
||||
return length;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue