Commit 8b48cbfc authored by twanvl's avatar twanvl

fixed loading images from zip packages

parent a7306af2
...@@ -131,6 +131,7 @@ void Package::saveAs(const String& name, bool removeUnused) { ...@@ -131,6 +131,7 @@ void Package::saveAs(const String& name, bool removeUnused) {
// ----------------------------------------------------------------------------- : Package : inside // ----------------------------------------------------------------------------- : Package : inside
/*
/// Class that is a wxZipInputStream over a wxFileInput stream /// Class that is a wxZipInputStream over a wxFileInput stream
/** Note that wxFileInputStream is also a base class, because it must be constructed first /** Note that wxFileInputStream is also a base class, because it must be constructed first
* This class requires a patch in wxWidgets (2.5.4) * This class requires a patch in wxWidgets (2.5.4)
...@@ -139,7 +140,9 @@ void Package::saveAs(const String& name, bool removeUnused) { ...@@ -139,7 +140,9 @@ void Package::saveAs(const String& name, bool removeUnused) {
* to: * to:
* if ((AtHeader())); * if ((AtHeader()));
* It seems that in 2.6.3 this is no longer necessary (TODO: test) * It seems that in 2.6.3 this is no longer necessary (TODO: test)
*/ *
* NOTE: Not used with wx 2.6.3, since it doesn't support seeking
* /
class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream { class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream {
public: public:
ZipFileInputStream(const String& filename, wxZipEntry* entry) ZipFileInputStream(const String& filename, wxZipEntry* entry)
...@@ -149,6 +152,7 @@ class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream { ...@@ -149,6 +152,7 @@ class ZipFileInputStream : private wxFileInputStream, public wxZipInputStream {
OpenEntry(*entry); OpenEntry(*entry);
} }
}; };
*/
InputStreamP Package::openIn(const String& file) { InputStreamP Package::openIn(const String& file) {
if (!file.empty() && file.GetChar(0) == _('/')) { if (!file.empty() && file.GetChar(0) == _('/')) {
...@@ -168,8 +172,10 @@ InputStreamP Package::openIn(const String& file) { ...@@ -168,8 +172,10 @@ InputStreamP Package::openIn(const String& file) {
stream = new_shared1<wxFileInputStream>(filename+_("/")+file); stream = new_shared1<wxFileInputStream>(filename+_("/")+file);
} else if (wxFileExists(filename) && it->second.zipEntry) { } else if (wxFileExists(filename) && it->second.zipEntry) {
// a file in a zip archive // a file in a zip archive
stream = static_pointer_cast<wxZipInputStream>( // somebody in wx thought seeking was no longer needed, it now only works with the 'compatability constructor'
new_shared2<ZipFileInputStream>(filename, it->second.zipEntry)); stream = new_shared2<wxZipInputStream>(filename, it->second.zipEntry->GetName());
//stream = static_pointer_cast<wxZipInputStream>(
// new_shared2<ZipFileInputStream>(filename, it->second.zipEntry));
} else { } else {
// shouldn't happen, packaged changed by someone else since opening it // shouldn't happen, packaged changed by someone else since opening it
throw FileNotFoundError(file, filename); throw FileNotFoundError(file, filename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment