diff options
author | Roland Lutz <rlutz@hedmen.org> | 2017-07-10 14:03:56 +0200 |
---|---|---|
committer | Roland Lutz <rlutz@hedmen.org> | 2017-09-04 15:51:03 +0200 |
commit | e9e49bb5db7a29e6b479c7e7c4c0bb6b6e90078b (patch) | |
tree | 673b974b946e61710fdf3d9ca28c22c2f1cfae7f | |
parent | 450306dfb14a866f070f7370286880564316d1a9 (diff) | |
download | icestorm-e9e49bb5db7a29e6b479c7e7c4c0bb6b6e90078b.tar.gz icestorm-e9e49bb5db7a29e6b479c7e7c4c0bb6b6e90078b.tar.bz2 icestorm-e9e49bb5db7a29e6b479c7e7c4c0bb6b6e90078b.zip |
icemulti: Add missing error checks
-rw-r--r-- | icemulti/icemulti.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/icemulti/icemulti.cc b/icemulti/icemulti.cc index 48e2512..42b4dcb 100644 --- a/icemulti/icemulti.cc +++ b/icemulti/icemulti.cc @@ -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; } |