diff options
| author | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2021-11-30 20:09:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-30 20:09:32 -0500 |
| commit | a3363333d809e8089a55efc3ea32eaea9ddb8d8c (patch) | |
| tree | 5cf25cc7a7fb5eebd2a1671f0e54a8e3335ebbce /ZAPD/ZFile.cpp | |
| parent | e3b53d3b8f88a0d139e72602c52666057e7066c0 (diff) | |
ZResource::GetSourceOutputCode no longer returns a string (#209)
* Updated nuget to use newer version of libpng. Also updated uses of std::filesystem::path to be compliant with MSVC implementation.
* Updated nuget to use newer version of libpng. Also updated uses of std::filesystem::path to be compliant with MSVC implementation.
* GetSourceOutputCode no longer uses strings, and some overrides were removed.
* Removed redundant GetSourceOutputHeader
* Fixed MSVC issue
* Changed libpng nuget package due to compilation issues. Other minor tweaks.
Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
Diffstat (limited to 'ZAPD/ZFile.cpp')
| -rw-r--r-- | ZAPD/ZFile.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/ZAPD/ZFile.cpp b/ZAPD/ZFile.cpp index 38482d9..77387fc 100644 --- a/ZAPD/ZFile.cpp +++ b/ZAPD/ZFile.cpp @@ -74,19 +74,13 @@ ZFile::ZFile(ZFileMode nMode, tinyxml2::XMLElement* reader, const fs::path& nBas ZFile::~ZFile() { for (ZResource* res : resources) - { delete res; - } for (auto d : declarations) - { delete d.second; - } for (auto sym : symbolResources) - { delete sym.second; - } } void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename) @@ -323,6 +317,11 @@ std::string ZFile::GetName() const return name; } +std::string ZFile::GetOutName() const +{ + return outName.string(); +} + ZFileMode ZFile::GetMode() const { return mode; @@ -357,8 +356,8 @@ void ZFile::ExtractResources() if (Globals::Instance->genSourceFile) GenerateSourceFiles(); - MemoryStream* memStream = new MemoryStream(); - BinaryWriter writer = BinaryWriter(memStream); + auto memStreamFile = std::shared_ptr<MemoryStream>(new MemoryStream()); + BinaryWriter writerFile = BinaryWriter(memStreamFile); ExporterSet* exporterSet = Globals::Instance->GetExporterSet(); @@ -367,6 +366,9 @@ void ZFile::ExtractResources() for (ZResource* res : resources) { + auto memStreamRes = std::shared_ptr<MemoryStream>(new MemoryStream()); + BinaryWriter writerRes = BinaryWriter(memStreamRes); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) printf("Saving resource %s\n", res->GetName().c_str()); @@ -375,18 +377,24 @@ void ZFile::ExtractResources() // Check if we have an exporter "registered" for this resource type ZResourceExporter* exporter = Globals::Instance->GetExporter(res->GetResourceType()); if (exporter != nullptr) - exporter->Save(res, Globals::Instance->outputPath.string(), &writer); + { + //exporter->Save(res, Globals::Instance->outputPath.string(), &writerFile); + exporter->Save(res, Globals::Instance->outputPath.string(), &writerRes); + } + + if (exporterSet != nullptr && exporterSet->resSaveFunc != nullptr) + exporterSet->resSaveFunc(res, writerRes); } - if (memStream->GetLength() > 0) + if (memStreamFile->GetLength() > 0) { File::WriteAllBytes(StringHelper::Sprintf("%s%s.bin", Globals::Instance->outputPath.string().c_str(), GetName().c_str()), - memStream->ToVector()); + memStreamFile->ToVector()); } - writer.Close(); + writerFile.Close(); if (exporterSet != nullptr && exporterSet->endFileFunc != nullptr) exporterSet->endFileFunc(this); |
