diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d57a56c86..263186315 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1076,6 +1076,7 @@ set (PCH_SOURCES common/utility/s_playlist.cpp common/utility/name.cpp common/utility/r_memory.cpp + common/utility/writezip.cpp common/thirdparty/base64.cpp common/thirdparty/md5.cpp common/thirdparty/superfasthash.cpp diff --git a/src/common/filesystem/include/fs_files.h b/src/common/filesystem/include/fs_files.h index 115b51704..8ad55953f 100644 --- a/src/common/filesystem/include/fs_files.h +++ b/src/common/filesystem/include/fs_files.h @@ -44,8 +44,6 @@ #include #include "fs_swap.h" -#include "tarray.h" - namespace FileSys { class FileSystemException : public std::exception diff --git a/src/common/filesystem/include/fs_findfile.h b/src/common/filesystem/include/fs_findfile.h index d845b7d14..d8a18c374 100644 --- a/src/common/filesystem/include/fs_findfile.h +++ b/src/common/filesystem/include/fs_findfile.h @@ -23,7 +23,6 @@ using FileList = std::vector; struct FCompressedBuffer; bool ScanDirectory(std::vector& list, const char* dirpath, const char* match, bool nosubdir = false, bool readhidden = false); -bool WriteZip(const char* filename, const FCompressedBuffer* content, size_t contentcount); bool FS_DirEntryExists(const char* pathname, bool* isdir); inline void FixPathSeparator(char* path) diff --git a/src/common/filesystem/source/w_zip.h b/src/common/filesystem/include/w_zip.h similarity index 99% rename from src/common/filesystem/source/w_zip.h rename to src/common/filesystem/include/w_zip.h index 3626a73cf..50c39519f 100644 --- a/src/common/filesystem/source/w_zip.h +++ b/src/common/filesystem/include/w_zip.h @@ -9,7 +9,6 @@ #include -namespace FileSys { #pragma pack(1) // FZipCentralInfo @@ -109,5 +108,4 @@ struct FZipLocalFileHeader // File header flags. #define ZF_ENCRYPTED 0x1 -} #endif diff --git a/src/common/filesystem/source/ancientzip.cpp b/src/common/filesystem/source/ancientzip.cpp index 4d1e6b990..1bc605bde 100644 --- a/src/common/filesystem/source/ancientzip.cpp +++ b/src/common/filesystem/source/ancientzip.cpp @@ -125,7 +125,7 @@ static const unsigned char BitReverse4[] = { #define FIRST_BIT_LEN 8 #define REST_BIT_LEN 4 -void FZipExploder::InsertCode(TArray &decoder, unsigned int pos, int bits, unsigned short code, int len, unsigned char value) +void FZipExploder::InsertCode(std::vector &decoder, unsigned int pos, int bits, unsigned short code, int len, unsigned char value) { assert(len > 0); unsigned int node = pos + (code & ((1 << bits) - 1)); @@ -161,10 +161,10 @@ void FZipExploder::InsertCode(TArray &decoder, unsigned int pos, int b } } -unsigned int FZipExploder::InitTable(TArray &decoder, int numspots) +unsigned int FZipExploder::InitTable(std::vector &decoder, int numspots) { - unsigned int start = decoder.Size(); - decoder.Reserve(numspots); + size_t start = decoder.size(); + decoder.resize(decoder.size() + numspots); memset(&decoder[start], 0, sizeof(HuffNode)*numspots); return start; } @@ -180,7 +180,7 @@ int FZipExploder::buildercmp(const void *a, const void *b) return d; } -int FZipExploder::BuildDecoder(TArray &decoder, TableBuilder *values, int numvals) +int FZipExploder::BuildDecoder(std::vector &decoder, TableBuilder *values, int numvals) { int i; @@ -218,7 +218,7 @@ int FZipExploder::BuildDecoder(TArray &decoder, TableBuilder *values, } -int FZipExploder::DecodeSFValue(const TArray &decoder) +int FZipExploder::DecodeSFValue(const std::vector &decoder) { unsigned int bits = FIRST_BIT_LEN, table = 0, code; const HuffNode *pos; @@ -236,7 +236,7 @@ int FZipExploder::DecodeSFValue(const TArray &decoder) } -int FZipExploder::DecodeSF(TArray &decoder, int numvals) +int FZipExploder::DecodeSF(std::vector &decoder, int numvals) { TableBuilder builder[256]; unsigned char a, c; diff --git a/src/common/filesystem/source/ancientzip.h b/src/common/filesystem/source/ancientzip.h index e25a75d3b..1f8d793fd 100644 --- a/src/common/filesystem/source/ancientzip.h +++ b/src/common/filesystem/source/ancientzip.h @@ -27,18 +27,18 @@ class FZipExploder unsigned short Code; }; - TArray LiteralDecoder; - TArray DistanceDecoder; - TArray LengthDecoder; + std::vector LiteralDecoder; + std::vector DistanceDecoder; + std::vector LengthDecoder; unsigned char ReadBuf[256]; unsigned int bs, be; static int buildercmp(const void *a, const void *b); - void InsertCode(TArray &decoder, unsigned int pos, int bits, unsigned short code, int len, unsigned char value); - unsigned int InitTable(TArray &decoder, int numspots); - int BuildDecoder(TArray &decoder, TableBuilder *values, int numvals); - int DecodeSFValue(const TArray ¤tTree); - int DecodeSF(TArray &decoder, int numvals); + void InsertCode(std::vector &decoder, unsigned int pos, int bits, unsigned short code, int len, unsigned char value); + unsigned int InitTable(std::vector &decoder, int numspots); + int BuildDecoder(std::vector &decoder, TableBuilder *values, int numvals); + int DecodeSFValue(const std::vector ¤tTree); + int DecodeSF(std::vector &decoder, int numvals); public: int Explode(unsigned char *out, unsigned int outsize, FileReader &in, unsigned int insize, int flags); }; diff --git a/src/common/filesystem/source/file_7z.cpp b/src/common/filesystem/source/file_7z.cpp index e709c3641..7efca8c9d 100644 --- a/src/common/filesystem/source/file_7z.cpp +++ b/src/common/filesystem/source/file_7z.cpp @@ -280,10 +280,9 @@ bool F7ZFile::Open(LumpFilterInfo *filter, FileSystemMessageFunc Printf) { // Quick check for unsupported compression method - TArray temp; - temp.Resize(Entries[0].Length); + FileData temp(nullptr, Entries[0].Length); - if (SZ_OK != Archive->Extract(Entries[0].Position, &temp[0])) + if (SZ_OK != Archive->Extract(Entries[0].Position, (char*)temp.writable())) { Printf(FSMessageLevel::Error, "%s: unsupported 7z/LZMA file!\n", FileName); return false; diff --git a/src/common/filesystem/source/file_pak.cpp b/src/common/filesystem/source/file_pak.cpp index 1156071f5..c1d559eb9 100644 --- a/src/common/filesystem/source/file_pak.cpp +++ b/src/common/filesystem/source/file_pak.cpp @@ -73,9 +73,9 @@ static bool OpenPak(FResourceFile* file, LumpFilterInfo* filter) auto Entries = file->AllocateEntries(NumLumps); header.dirofs = LittleLong(header.dirofs); - TArray fileinfo(NumLumps, true); Reader->Seek (header.dirofs, FileReader::SeekSet); - Reader->Read (fileinfo.Data(), NumLumps * sizeof(dpackfile_t)); + auto fd = Reader->Read (NumLumps * sizeof(dpackfile_t)); + auto fileinfo = (const dpackfile_t*)fd.data(); for(uint32_t i = 0; i < NumLumps; i++) { diff --git a/src/common/filesystem/source/file_wad.cpp b/src/common/filesystem/source/file_wad.cpp index 8a81b3ced..c35d4ce59 100644 --- a/src/common/filesystem/source/file_wad.cpp +++ b/src/common/filesystem/source/file_wad.cpp @@ -122,9 +122,9 @@ bool FWadFile::Open(LumpFilterInfo*, FileSystemMessageFunc Printf) } } - TArray fileinfo(NumLumps, true); - Reader.Seek (InfoTableOfs, FileReader::SeekSet); - Reader.Read (fileinfo.Data(), NumLumps * sizeof(wadlump_t)); + Reader.Seek(InfoTableOfs, FileReader::SeekSet); + auto fd = Reader.Read(NumLumps * sizeof(wadlump_t)); + auto fileinfo = (const wadlump_t*)fd.data(); AllocateEntries(NumLumps); @@ -214,20 +214,20 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name bool warned = false; int numstartmarkers = 0, numendmarkers = 0; unsigned int i; - TArray markers; + std::vector markers; for(i = 0; i < NumLumps; i++) { if (IsMarker(i, startmarker)) { Marker m = { 0, i }; - markers.Push(m); + markers.push_back(m); numstartmarkers++; } else if (IsMarker(i, endmarker)) { Marker m = { 1, i }; - markers.Push(m); + markers.push_back(m); numendmarkers++; } } @@ -243,7 +243,7 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name { // We have found no F_START but one or more F_END markers. // mark all lumps before the last F_END marker as potential flats. - unsigned int end = markers[markers.Size()-1].index; + unsigned int end = markers[markers.size()-1].index; for(unsigned int ii = 0; ii < end; ii++) { if (Entries[ii].Length == 4096) @@ -259,7 +259,7 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name } i = 0; - while (i < markers.Size()) + while (i < markers.size()) { int start, end; if (markers[i].markertype != 0) @@ -271,21 +271,21 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name start = i++; // skip over subsequent x_START markers - while (i < markers.Size() && markers[i].markertype == 0) + while (i < markers.size() && markers[i].markertype == 0) { Printf(FSMessageLevel::Warning, "%s: duplicate %s marker found.\n", FileName, startmarker); i++; continue; } // same for x_END markers - while (i < markers.Size()-1 && (markers[i].markertype == 1 && markers[i+1].markertype == 1)) + while (i < markers.size()-1 && (markers[i].markertype == 1 && markers[i+1].markertype == 1)) { Printf(FSMessageLevel::Warning, "%s: duplicate %s marker found.\n", FileName, endmarker); i++; continue; } // We found a starting marker but no end marker. Ignore this block. - if (i >= markers.Size()) + if (i >= markers.size()) { Printf(FSMessageLevel::Warning, "%s: %s marker without corresponding %s found.\n", FileName, startmarker, endmarker); end = NumLumps; diff --git a/src/common/filesystem/source/file_zip.cpp b/src/common/filesystem/source/file_zip.cpp index 95d05c604..3356fc1fa 100644 --- a/src/common/filesystem/source/file_zip.cpp +++ b/src/common/filesystem/source/file_zip.cpp @@ -3,7 +3,7 @@ ** **--------------------------------------------------------------------------- ** Copyright 1998-2009 Randy Heit -** Copyright 2005-2009 Christoph Oelckers +** Copyright 2005-2023 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without @@ -395,199 +395,4 @@ FResourceFile *CheckZip(const char *filename, FileReader &file, LumpFilterInfo* } - -//========================================================================== -// -// time_to_dos -// -// Converts time from struct tm to the DOS format used by zip files. -// -//========================================================================== - -static std::pair time_to_dos(struct tm *time) -{ - std::pair val; - if (time == NULL || time->tm_year < 80) - { - val.first = val.second = 0; - } - else - { - val.first = (time->tm_year - 80) * 512 + (time->tm_mon + 1) * 32 + time->tm_mday; - val.second= time->tm_hour * 2048 + time->tm_min * 32 + time->tm_sec / 2; - } - return val; -} - -//========================================================================== -// -// append_to_zip -// -// Write a given file to the zipFile. -// -// zipfile: zip object to be written to -// -// returns: position = success, -1 = error -// -//========================================================================== - -static int AppendToZip(FileWriter *zip_file, const FCompressedBuffer &content, std::pair &dostime) -{ - FZipLocalFileHeader local; - int position; - - int flags = 0; - int method = content.mMethod; - if (method >= METHOD_IMPLODE_MIN && method <= METHOD_IMPLODE_MAX) - { - flags = method - METHOD_IMPLODE_MIN; - method = METHOD_IMPLODE; - } - else if (method == METHOD_DEFLATE) - { - flags = 2; - } - else if (method >= 1337) - return -1; - - local.Magic = ZIP_LOCALFILE; - local.VersionToExtract[0] = 20; - local.VersionToExtract[1] = 0; - local.Flags = LittleShort((uint16_t)flags); - local.Method = LittleShort((uint16_t)method); - local.ModDate = LittleShort(dostime.first); - local.ModTime = LittleShort(dostime.second); - local.CRC32 = content.mCRC32; - local.UncompressedSize = LittleLong((unsigned)content.mSize); - local.CompressedSize = LittleLong((unsigned)content.mCompressedSize); - local.NameLength = LittleShort((unsigned short)strlen(content.filename)); - local.ExtraLength = 0; - - // Fill in local directory header. - - position = (int)zip_file->Tell(); - - // Write out the header, file name, and file data. - if (zip_file->Write(&local, sizeof(local)) != sizeof(local) || - zip_file->Write(content.filename, strlen(content.filename)) != strlen(content.filename) || - zip_file->Write(content.mBuffer, content.mCompressedSize) != content.mCompressedSize) - { - return -1; - } - return position; -} - - -//========================================================================== -// -// write_central_dir -// -// Writes the central directory entry for a file. -// -//========================================================================== - -int AppendCentralDirectory(FileWriter *zip_file, const FCompressedBuffer &content, std::pair &dostime, int position) -{ - FZipCentralDirectoryInfo dir; - - int flags = 0; - int method = content.mMethod; - if (method >= METHOD_IMPLODE_MIN && method <= METHOD_IMPLODE_MAX) - { - flags = method - METHOD_IMPLODE_MIN; - method = METHOD_IMPLODE; - } - else if (method == METHOD_DEFLATE) - { - flags = 2; - } - else if (method >= 1337) - return -1; - - dir.Magic = ZIP_CENTRALFILE; - dir.VersionMadeBy[0] = 20; - dir.VersionMadeBy[1] = 0; - dir.VersionToExtract[0] = 20; - dir.VersionToExtract[1] = 0; - dir.Flags = LittleShort((uint16_t)flags); - dir.Method = LittleShort((uint16_t)method); - dir.ModTime = LittleShort(dostime.first); - dir.ModDate = LittleShort(dostime.second); - dir.CRC32 = content.mCRC32; - dir.CompressedSize32 = LittleLong((unsigned)content.mCompressedSize); - dir.UncompressedSize32 = LittleLong((unsigned)content.mSize); - dir.NameLength = LittleShort((unsigned short)strlen(content.filename)); - dir.ExtraLength = 0; - dir.CommentLength = 0; - dir.StartingDiskNumber = 0; - dir.InternalAttributes = 0; - dir.ExternalAttributes = 0; - dir.LocalHeaderOffset32 = LittleLong((unsigned)position); - - if (zip_file->Write(&dir, sizeof(dir)) != sizeof(dir) || - zip_file->Write(content.filename, strlen(content.filename)) != strlen(content.filename)) - { - return -1; - } - return 0; -} - -bool WriteZip(const char* filename, const FCompressedBuffer* content, size_t contentcount) -{ - // try to determine local time - struct tm *ltime; - time_t ttime; - ttime = time(nullptr); - ltime = localtime(&ttime); - auto dostime = time_to_dos(ltime); - - TArray positions; - - auto f = FileWriter::Open(filename); - if (f != nullptr) - { - for (size_t i = 0; i < contentcount; i++) - { - int pos = AppendToZip(f, content[i], dostime); - if (pos == -1) - { - delete f; - remove(filename); - return false; - } - positions.Push(pos); - } - - int dirofs = (int)f->Tell(); - for (size_t i = 0; i < contentcount; i++) - { - if (AppendCentralDirectory(f, content[i], dostime, positions[i]) < 0) - { - delete f; - remove(filename); - return false; - } - } - - // Write the directory terminator. - FZipEndOfCentralDirectory dirend; - dirend.Magic = ZIP_ENDOFDIR; - dirend.DiskNumber = 0; - dirend.FirstDisk = 0; - dirend.NumEntriesOnAllDisks = dirend.NumEntries = LittleShort((uint16_t)contentcount); - dirend.DirectoryOffset = LittleLong((unsigned)dirofs); - dirend.DirectorySize = LittleLong((uint32_t)(f->Tell() - dirofs)); - dirend.ZipCommentLength = 0; - if (f->Write(&dirend, sizeof(dirend)) != sizeof(dirend)) - { - delete f; - remove(filename); - return false; - } - delete f; - return true; - } - return false; -} - } diff --git a/src/common/utility/writezip.cpp b/src/common/utility/writezip.cpp new file mode 100644 index 000000000..5c0b0e65b --- /dev/null +++ b/src/common/utility/writezip.cpp @@ -0,0 +1,239 @@ +/* +** writezip.cpp +** +**--------------------------------------------------------------------------- +** Copyright 1998-2009 Randy Heit +** Copyright 2005-2023 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#include +#include +#include "tarray.h" +#include "files.h" +#include "m_swap.h" +#include "w_zip.h" + +using FileSys::FCompressedBuffer; + + + +//========================================================================== +// +// time_to_dos +// +// Converts time from struct tm to the DOS format used by zip files. +// +//========================================================================== + +static std::pair time_to_dos(struct tm *time) +{ + std::pair val; + if (time == NULL || time->tm_year < 80) + { + val.first = val.second = 0; + } + else + { + val.first = (time->tm_year - 80) * 512 + (time->tm_mon + 1) * 32 + time->tm_mday; + val.second= time->tm_hour * 2048 + time->tm_min * 32 + time->tm_sec / 2; + } + return val; +} + +//========================================================================== +// +// append_to_zip +// +// Write a given file to the zipFile. +// +// zipfile: zip object to be written to +// +// returns: position = success, -1 = error +// +//========================================================================== + +static int AppendToZip(FileWriter *zip_file, const FCompressedBuffer &content, std::pair &dostime) +{ + FZipLocalFileHeader local; + int position; + + int flags = 0; + int method = content.mMethod; + if (method >= FileSys::METHOD_IMPLODE_MIN && method <= FileSys::METHOD_IMPLODE_MAX) + { + flags = method - FileSys::METHOD_IMPLODE_MIN; + method = FileSys::METHOD_IMPLODE; + } + else if (method == FileSys::METHOD_DEFLATE) + { + flags = 2; + } + else if (method >= 1337) + return -1; + + local.Magic = ZIP_LOCALFILE; + local.VersionToExtract[0] = 20; + local.VersionToExtract[1] = 0; + local.Flags = LittleShort((uint16_t)flags); + local.Method = LittleShort((uint16_t)method); + local.ModDate = LittleShort(dostime.first); + local.ModTime = LittleShort(dostime.second); + local.CRC32 = content.mCRC32; + local.UncompressedSize = LittleLong((unsigned)content.mSize); + local.CompressedSize = LittleLong((unsigned)content.mCompressedSize); + local.NameLength = LittleShort((unsigned short)strlen(content.filename)); + local.ExtraLength = 0; + + // Fill in local directory header. + + position = (int)zip_file->Tell(); + + // Write out the header, file name, and file data. + if (zip_file->Write(&local, sizeof(local)) != sizeof(local) || + zip_file->Write(content.filename, strlen(content.filename)) != strlen(content.filename) || + zip_file->Write(content.mBuffer, content.mCompressedSize) != content.mCompressedSize) + { + return -1; + } + return position; +} + + +//========================================================================== +// +// write_central_dir +// +// Writes the central directory entry for a file. +// +//========================================================================== + +int AppendCentralDirectory(FileWriter *zip_file, const FCompressedBuffer &content, std::pair &dostime, int position) +{ + FZipCentralDirectoryInfo dir; + + int flags = 0; + int method = content.mMethod; + if (method >= FileSys::METHOD_IMPLODE_MIN && method <= FileSys::METHOD_IMPLODE_MAX) + { + flags = method - FileSys::METHOD_IMPLODE_MIN; + method = FileSys::METHOD_IMPLODE; + } + else if (method == FileSys::METHOD_DEFLATE) + { + flags = 2; + } + else if (method >= 1337) + return -1; + + dir.Magic = ZIP_CENTRALFILE; + dir.VersionMadeBy[0] = 20; + dir.VersionMadeBy[1] = 0; + dir.VersionToExtract[0] = 20; + dir.VersionToExtract[1] = 0; + dir.Flags = LittleShort((uint16_t)flags); + dir.Method = LittleShort((uint16_t)method); + dir.ModTime = LittleShort(dostime.first); + dir.ModDate = LittleShort(dostime.second); + dir.CRC32 = content.mCRC32; + dir.CompressedSize32 = LittleLong((unsigned)content.mCompressedSize); + dir.UncompressedSize32 = LittleLong((unsigned)content.mSize); + dir.NameLength = LittleShort((unsigned short)strlen(content.filename)); + dir.ExtraLength = 0; + dir.CommentLength = 0; + dir.StartingDiskNumber = 0; + dir.InternalAttributes = 0; + dir.ExternalAttributes = 0; + dir.LocalHeaderOffset32 = LittleLong((unsigned)position); + + if (zip_file->Write(&dir, sizeof(dir)) != sizeof(dir) || + zip_file->Write(content.filename, strlen(content.filename)) != strlen(content.filename)) + { + return -1; + } + return 0; +} + +bool WriteZip(const char* filename, const FCompressedBuffer* content, size_t contentcount) +{ + // try to determine local time + struct tm *ltime; + time_t ttime; + ttime = time(nullptr); + ltime = localtime(&ttime); + auto dostime = time_to_dos(ltime); + + TArray positions; + + auto f = FileWriter::Open(filename); + if (f != nullptr) + { + for (size_t i = 0; i < contentcount; i++) + { + int pos = AppendToZip(f, content[i], dostime); + if (pos == -1) + { + delete f; + remove(filename); + return false; + } + positions.Push(pos); + } + + int dirofs = (int)f->Tell(); + for (size_t i = 0; i < contentcount; i++) + { + if (AppendCentralDirectory(f, content[i], dostime, positions[i]) < 0) + { + delete f; + remove(filename); + return false; + } + } + + // Write the directory terminator. + FZipEndOfCentralDirectory dirend; + dirend.Magic = ZIP_ENDOFDIR; + dirend.DiskNumber = 0; + dirend.FirstDisk = 0; + dirend.NumEntriesOnAllDisks = dirend.NumEntries = LittleShort((uint16_t)contentcount); + dirend.DirectoryOffset = LittleLong((unsigned)dirofs); + dirend.DirectorySize = LittleLong((uint32_t)(f->Tell() - dirofs)); + dirend.ZipCommentLength = 0; + if (f->Write(&dirend, sizeof(dirend)) != sizeof(dirend)) + { + delete f; + remove(filename); + return false; + } + delete f; + return true; + } + return false; +} diff --git a/src/g_game.cpp b/src/g_game.cpp index eb6f45b0c..397f9eb75 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -96,6 +96,7 @@ static FRandom pr_dmspawn ("DMSpawn"); static FRandom pr_pspawn ("PlayerSpawn"); +bool WriteZip(const char* filename, const FileSys::FCompressedBuffer* content, size_t contentcount); bool G_CheckDemoStatus (void); void G_ReadDemoTiccmd (ticcmd_t *cmd, int player); void G_WriteDemoTiccmd (ticcmd_t *cmd, int player, int buf);