2021-10-15 15:41:16 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2021 Maschell
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "utils/utils.h"
|
|
|
|
#include "WUDFileWriter.h"
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned int magic0;
|
|
|
|
unsigned int magic1;
|
|
|
|
unsigned int sectorSize;
|
|
|
|
unsigned long long uncompressedSize;
|
|
|
|
unsigned int flags;
|
|
|
|
} wuxHeader_t;
|
|
|
|
|
|
|
|
#define WUX_MAGIC_0 0x57555830
|
|
|
|
#define WUX_MAGIC_1 swap_uint32(0x1099d02e)
|
|
|
|
|
|
|
|
class WUXFileWriter : public WUDFileWriter {
|
|
|
|
public:
|
2021-10-16 13:03:32 +02:00
|
|
|
WUXFileWriter(const char *string, int32_t cacheSize, int32_t pSectorSize, bool split = false);
|
2021-10-15 15:41:16 +02:00
|
|
|
|
|
|
|
~WUXFileWriter() override;
|
|
|
|
|
|
|
|
int32_t writeSector(const uint8_t *buffer, uint32_t numberOfSectors) override;
|
|
|
|
|
2021-10-16 13:03:32 +02:00
|
|
|
void finalize() override;
|
2021-10-15 15:41:16 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void writeSectorIndexTable();
|
|
|
|
|
|
|
|
uint64_t totalSectorCount;
|
|
|
|
|
|
|
|
uint64_t sectorTableStart;
|
|
|
|
uint64_t sectorTableEnd;
|
|
|
|
void *sectorIndexTable = nullptr;
|
|
|
|
|
|
|
|
std::map<std::string, uint32_t> hashMap;
|
|
|
|
uint32_t currentSector = 0;
|
|
|
|
uint32_t writtenSector = 0;
|
|
|
|
};
|