mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 12:11:25 +00:00
moved private definitions out of public headers.
This commit is contained in:
parent
ebb71cebf1
commit
c77ece4922
15 changed files with 111 additions and 105 deletions
|
@ -101,31 +101,6 @@ public:
|
|||
long GetLength () const { return Length; }
|
||||
};
|
||||
|
||||
class MemoryReader : public FileReaderInterface
|
||||
{
|
||||
protected:
|
||||
const char * bufptr = nullptr;
|
||||
long FilePos = 0;
|
||||
|
||||
MemoryReader()
|
||||
{}
|
||||
|
||||
public:
|
||||
MemoryReader(const char *buffer, long length)
|
||||
{
|
||||
bufptr = buffer;
|
||||
Length = length;
|
||||
FilePos = 0;
|
||||
}
|
||||
|
||||
long Tell() const override;
|
||||
long Seek(long offset, int origin) override;
|
||||
long Read(void *buffer, long len) override;
|
||||
char *Gets(char *strbuf, int len) override;
|
||||
virtual const char *GetBuffer() const override { return bufptr; }
|
||||
};
|
||||
|
||||
|
||||
struct FResourceLump;
|
||||
|
||||
class FileReader
|
||||
|
@ -329,24 +304,6 @@ public:
|
|||
friend class FileSystem;
|
||||
};
|
||||
|
||||
class DecompressorBase : public FileReaderInterface
|
||||
{
|
||||
bool exceptions = false;
|
||||
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 SetOwnsReader();
|
||||
void EnableExceptions(bool on) { exceptions = on; }
|
||||
|
||||
protected:
|
||||
FileReader* File = nullptr;
|
||||
FileReader OwnedFile;
|
||||
};
|
||||
|
||||
|
||||
class FileWriter
|
||||
{
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
|
||||
namespace FileSys {
|
||||
|
||||
class FResourceFile;
|
||||
struct FResourceLump;
|
||||
|
||||
union LumpShortName
|
||||
{
|
||||
char String[9];
|
||||
|
|
|
@ -197,56 +197,6 @@ public:
|
|||
FResourceLump *FindLump(const char *name);
|
||||
};
|
||||
|
||||
struct FUncompressedLump : public FResourceLump
|
||||
{
|
||||
int Position;
|
||||
|
||||
virtual FileReader *GetReader();
|
||||
virtual int FillCache() override;
|
||||
virtual int GetFileOffset() { return Position; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Base class for uncompressed resource files (WAD, GRP, PAK and single lumps)
|
||||
class FUncompressedFile : public FResourceFile
|
||||
{
|
||||
protected:
|
||||
TArray<FUncompressedLump> Lumps;
|
||||
|
||||
FUncompressedFile(const char *filename, StringPool* sp);
|
||||
FUncompressedFile(const char *filename, FileReader &r, StringPool* sp);
|
||||
virtual FResourceLump *GetLump(int no) { return ((unsigned)no < NumLumps)? &Lumps[no] : NULL; }
|
||||
};
|
||||
|
||||
|
||||
// should only be used internally.
|
||||
struct FExternalLump : public FResourceLump
|
||||
{
|
||||
const char* FileName;
|
||||
|
||||
FExternalLump(const char *_filename, int filesize, StringPool* sp);
|
||||
virtual int FillCache() override;
|
||||
|
||||
};
|
||||
|
||||
struct FMemoryLump : public FResourceLump
|
||||
{
|
||||
FMemoryLump(const void* data, int length)
|
||||
{
|
||||
RefCount = INT_MAX / 2;
|
||||
LumpSize = length;
|
||||
Cache = new char[length];
|
||||
memcpy(Cache, data, length);
|
||||
}
|
||||
|
||||
virtual int FillCache() override
|
||||
{
|
||||
RefCount = INT_MAX / 2; // Make sure it never counts down to 0 by resetting it to something high each time it is used.
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "resourcefile.h"
|
||||
#include "resourcefile_internal.h"
|
||||
#include "fs_swap.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "resourcefile.h"
|
||||
#include "resourcefile_internal.h"
|
||||
|
||||
namespace FileSys {
|
||||
//==========================================================================
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "resourcefile.h"
|
||||
#include "resourcefile_internal.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "resourcefile.h"
|
||||
#include "resourcefile_internal.h"
|
||||
#include "fs_swap.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "resourcefile.h"
|
||||
#include "resourcefile_internal.h"
|
||||
|
||||
namespace FileSys {
|
||||
//==========================================================================
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "resourcefile.h"
|
||||
#include "resourcefile_internal.h"
|
||||
#include "fs_stringpool.h"
|
||||
#include "fs_swap.h"
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <string>
|
||||
#include "fs_files.h"
|
||||
#include "files_internal.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
|
|
|
@ -46,6 +46,26 @@
|
|||
namespace FileSys {
|
||||
using namespace byteswap;
|
||||
|
||||
|
||||
class DecompressorBase : public FileReaderInterface
|
||||
{
|
||||
bool exceptions = false;
|
||||
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 SetOwnsReader();
|
||||
void EnableExceptions(bool on) { exceptions = on; }
|
||||
|
||||
protected:
|
||||
FileReader* File = nullptr;
|
||||
FileReader OwnedFile;
|
||||
};
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DecompressionError
|
||||
|
|
31
src/common/filesystem/source/files_internal.h
Normal file
31
src/common/filesystem/source/files_internal.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include "fs_files.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
class MemoryReader : public FileReaderInterface
|
||||
{
|
||||
protected:
|
||||
const char * bufptr = nullptr;
|
||||
long FilePos = 0;
|
||||
|
||||
MemoryReader()
|
||||
{}
|
||||
|
||||
public:
|
||||
MemoryReader(const char *buffer, long length)
|
||||
{
|
||||
bufptr = buffer;
|
||||
Length = length;
|
||||
FilePos = 0;
|
||||
}
|
||||
|
||||
long Tell() const override;
|
||||
long Seek(long offset, int origin) override;
|
||||
long Read(void *buffer, long len) override;
|
||||
char *Gets(char *strbuf, int len) override;
|
||||
virtual const char *GetBuffer() const override { return bufptr; }
|
||||
};
|
||||
|
||||
}
|
|
@ -41,6 +41,7 @@
|
|||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "resourcefile_internal.h"
|
||||
#include "fs_filesystem.h"
|
||||
#include "fs_findfile.h"
|
||||
#include "md5.hpp"
|
||||
|
@ -320,10 +321,21 @@ int FileSystem::AddExternalFile(const char *filename)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
struct FMemoryLump : public FResourceLump
|
||||
{
|
||||
FMemoryLump(const void* data, int length)
|
||||
{
|
||||
RefCount = -1;
|
||||
LumpSize = length;
|
||||
Cache = new char[length];
|
||||
memcpy(Cache, data, length);
|
||||
}
|
||||
};
|
||||
|
||||
int FileSystem::AddFromBuffer(const char* name, const char* type, char* data, int size, int id, int flags)
|
||||
{
|
||||
std::string fullname = name;
|
||||
fullname += ':';
|
||||
fullname += '.';
|
||||
fullname += type;
|
||||
auto newlump = new FMemoryLump(data, size);
|
||||
newlump->LumpNameSetup(fullname.c_str(), stringpool);
|
||||
|
|
|
@ -35,9 +35,10 @@
|
|||
*/
|
||||
|
||||
#include <zlib.h>
|
||||
#include "resourcefile.h"
|
||||
#include "resourcefile_internal.h"
|
||||
#include "md5.hpp"
|
||||
#include "fs_stringpool.h"
|
||||
#include "files_internal.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
|
|
38
src/common/filesystem/source/resourcefile_internal.h
Normal file
38
src/common/filesystem/source/resourcefile_internal.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include "resourcefile.h"
|
||||
|
||||
namespace FileSys {
|
||||
struct FUncompressedLump : public FResourceLump
|
||||
{
|
||||
int Position;
|
||||
|
||||
virtual FileReader *GetReader();
|
||||
virtual int FillCache() override;
|
||||
virtual int GetFileOffset() { return Position; }
|
||||
|
||||
};
|
||||
|
||||
// Base class for uncompressed resource files (WAD, GRP, PAK and single lumps)
|
||||
class FUncompressedFile : public FResourceFile
|
||||
{
|
||||
protected:
|
||||
TArray<FUncompressedLump> Lumps;
|
||||
|
||||
FUncompressedFile(const char *filename, StringPool* sp);
|
||||
FUncompressedFile(const char *filename, FileReader &r, StringPool* sp);
|
||||
virtual FResourceLump *GetLump(int no) { return ((unsigned)no < NumLumps)? &Lumps[no] : NULL; }
|
||||
};
|
||||
|
||||
|
||||
// should only be used internally.
|
||||
struct FExternalLump : public FResourceLump
|
||||
{
|
||||
const char* FileName;
|
||||
|
||||
FExternalLump(const char *_filename, int filesize, StringPool* sp);
|
||||
virtual int FillCache() override;
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue