2019-11-06 11:29:08 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-11-14 20:07:43 +00:00
|
|
|
#include <assert.h>
|
2019-11-06 11:29:08 +00:00
|
|
|
#include "files.h"
|
|
|
|
#include "zstring.h"
|
|
|
|
#include "tarray.h"
|
2020-04-11 21:54:33 +00:00
|
|
|
#include "resourcefile.h"
|
2019-11-06 11:29:08 +00:00
|
|
|
|
|
|
|
class CompositeSavegameWriter
|
|
|
|
{
|
2019-11-14 20:07:43 +00:00
|
|
|
FString filename;
|
2019-11-06 11:29:08 +00:00
|
|
|
TDeletingArray<BufferWriter*> subfiles;
|
2020-02-23 08:41:12 +00:00
|
|
|
TArray<FCompressedBuffer> subbuffers;
|
2019-11-06 11:29:08 +00:00
|
|
|
TArray<FString> subfilenames;
|
|
|
|
TArray<bool> isCompressed;
|
2019-11-14 20:07:43 +00:00
|
|
|
|
|
|
|
FCompressedBuffer CompressElement(BufferWriter* element, bool compress);
|
2019-11-06 11:29:08 +00:00
|
|
|
public:
|
2019-11-14 20:07:43 +00:00
|
|
|
void Clear()
|
|
|
|
{
|
2020-02-23 08:41:12 +00:00
|
|
|
for (auto& b : subbuffers) b.Clean();
|
2020-01-07 17:53:16 +00:00
|
|
|
isCompressed.Clear();
|
|
|
|
subfilenames.Clear();
|
2020-01-06 19:01:18 +00:00
|
|
|
subfiles.DeleteAndClear();
|
2020-02-23 08:41:12 +00:00
|
|
|
subbuffers.Clear();
|
2020-01-07 17:53:16 +00:00
|
|
|
filename = "";
|
2019-11-14 20:07:43 +00:00
|
|
|
}
|
|
|
|
void SetFileName(const char* fn)
|
|
|
|
{
|
|
|
|
filename = fn;
|
|
|
|
}
|
|
|
|
void SetFileName(const FString& fn)
|
|
|
|
{
|
|
|
|
filename = fn;
|
|
|
|
}
|
|
|
|
~CompositeSavegameWriter()
|
|
|
|
{
|
|
|
|
assert(subfiles.Size() == 0); // must be written out.
|
|
|
|
}
|
|
|
|
FileWriter& NewElement(const char* filename, bool compress = true);
|
2020-02-23 08:41:12 +00:00
|
|
|
void AddCompressedElement(const char* filename, FCompressedBuffer& buffer);
|
2019-11-14 20:07:43 +00:00
|
|
|
bool WriteToFile();
|
2019-11-06 11:29:08 +00:00
|
|
|
};
|
|
|
|
|