- fixed compilation.

This commit is contained in:
Christoph Oelckers 2019-11-08 17:41:19 +01:00
parent 9aa275f996
commit f52a58d9ac
2 changed files with 26 additions and 23 deletions

View file

@ -59,6 +59,8 @@ enum
METHOD_TRANSFEROWNER = 0x8000, METHOD_TRANSFEROWNER = 0x8000,
}; };
class FileReader;
class FileReaderInterface class FileReaderInterface
{ {
public: public:
@ -72,27 +74,6 @@ public:
long GetLength () const { return Length; } long GetLength () const { return Length; }
}; };
class DecompressorBase : public FileReaderInterface
{
std::function<void(const char*)> ErrorCallback = nullptr;
public:
// These do not work but need to be defined to satisfy the FileReaderInterface.
// They will just error out when called.
long Tell() const override;
long Seek(long offset, int origin) override;
char *Gets(char *strbuf, int len) override;
void DecompressionError(const char* error, ...) const;
void SetErrorCallback(const std::function<void(const char*)>& cb)
{
ErrorCallback = cb;
}
void SetOwnsReader();
protected:
FileReader *File = nullptr;
FileReader OwnedFile;
};
class MemoryReader : public FileReaderInterface class MemoryReader : public FileReaderInterface
{ {
protected: protected:
@ -307,6 +288,28 @@ public:
friend class FWadCollection; friend class FWadCollection;
}; };
class DecompressorBase : public FileReaderInterface
{
std::function<void(const char*)> ErrorCallback = nullptr;
public:
// These do not work but need to be defined to satisfy the FileReaderInterface.
// They will just error out when called.
long Tell() const override;
long Seek(long offset, int origin) override;
char* Gets(char* strbuf, int len) override;
void DecompressionError(const char* error, ...) const;
void SetErrorCallback(const std::function<void(const char*)>& cb)
{
ErrorCallback = cb;
}
void SetOwnsReader();
protected:
FileReader* File = nullptr;
FileReader OwnedFile;
};

View file

@ -568,7 +568,7 @@ class DecompressorLZSS : public DecompressorBase
} }
public: public:
DecompressorLZSS(FileReader *file, const std::function<void(const char*)>& cb) : File(file), SawEOF(false) DecompressorLZSS(FileReader *file, const std::function<void(const char*)>& cb) : SawEOF(false)
{ {
File = file; File = file;
SetErrorCallback(cb); SetErrorCallback(cb);
@ -782,7 +782,7 @@ void CompressedFileWriter::Close()
break; break;
} }
auto err = deflate (zipstream, Z_FINISH); auto err = deflate (zipstream, Z_FINISH);
done = stream.avail_out != 0 || err == Z_STREAM_END; done = zipstream->avail_out != 0 || err == Z_STREAM_END;
if (err != Z_STREAM_END && err != Z_OK) if (err != Z_STREAM_END && err != Z_OK)
{ {
break; break;