diff options
Diffstat (limited to 'icemulti')
-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; } |