-
-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for memory card dumps in save data imports.
- Loading branch information
Showing
7 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "McDumpSaveImporter.h" | ||
#include "StdStreamUtils.h" | ||
|
||
void CMcDumpSaveImporter::Import(Framework::CStream& input, const fs::path& basePath) | ||
{ | ||
CMcDumpReader reader(input); | ||
auto dir = reader.ReadRootDirectory(); | ||
ImportDirectory(reader, dir, basePath); | ||
} | ||
|
||
void CMcDumpSaveImporter::ImportDirectory(CMcDumpReader& reader, const CMcDumpReader::Directory& dir, const fs::path& basePath) | ||
{ | ||
if(!fs::exists(basePath)) | ||
{ | ||
fs::create_directory(basePath); | ||
} | ||
|
||
for(const auto& dirEntry : dir) | ||
{ | ||
if(!strcmp(dirEntry.name, ".")) continue; | ||
if(!strcmp(dirEntry.name, "..")) continue; | ||
auto entryOutputPath = basePath / dirEntry.name; | ||
if(dirEntry.mode & CMcDumpReader::DF_DIRECTORY) | ||
{ | ||
auto subDir = reader.ReadDirectory(dirEntry.cluster, dirEntry.length); | ||
ImportDirectory(reader, subDir, entryOutputPath); | ||
} | ||
else | ||
{ | ||
if(CanExtractFile(entryOutputPath)) | ||
{ | ||
auto fileContents = reader.ReadFile(dirEntry.cluster, dirEntry.length); | ||
assert(fileContents.size() == dirEntry.length); | ||
auto output = Framework::CreateOutputStdStream(entryOutputPath.native()); | ||
output.Write(fileContents.data(), fileContents.size()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include "SaveImporterBase.h" | ||
#include "McDumpReader.h" | ||
|
||
class CMcDumpSaveImporter : public CSaveImporterBase | ||
{ | ||
public: | ||
virtual ~CMcDumpSaveImporter() = default; | ||
|
||
void Import(Framework::CStream&, const fs::path&) override; | ||
|
||
private: | ||
void ImportDirectory(CMcDumpReader&, const CMcDumpReader::Directory&, const fs::path&); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters