-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Jayveer/feature/darqar
Added support to extract from dar and qar files
- Loading branch information
Showing
12 changed files
with
267 additions
and
14 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
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,52 @@ | ||
#include "dar.h" | ||
|
||
Dar::Dar(std::string filename) { | ||
this->filename = filename; | ||
} | ||
|
||
Dar::~Dar() { | ||
|
||
} | ||
|
||
int32_t Dar::getNumFiles() { | ||
return this->numFiles; | ||
} | ||
|
||
std::vector<uint8_t> Dar::getFile(int32_t i) { | ||
return this->files[i].data; | ||
} | ||
|
||
void Dar::open() { | ||
std::ifstream darDat; | ||
darDat.open(filename, std::ios::binary); | ||
darDat.read((char*)&this->numFiles, 4); | ||
|
||
for (int i = 0; i < this->numFiles; i++) { | ||
int align; | ||
DarEntry entry; | ||
|
||
std::getline(darDat, entry.filename, '\0'); | ||
align = getAlignment(darDat.tellg(), 4); | ||
darDat.seekg(align, darDat.cur); | ||
|
||
darDat.read((char*)&entry.size, 4); | ||
align = getAlignment(darDat.tellg(), 16); | ||
darDat.seekg(align, darDat.cur); | ||
|
||
entry.data.resize(entry.size); | ||
darDat.read((char*)&entry.data[0], entry.size); | ||
darDat.seekg(1, darDat.cur); | ||
|
||
files.push_back(entry); | ||
} | ||
|
||
darDat.close(); | ||
} | ||
|
||
void Dar::extract(std::string output) { | ||
updateDir("Dar", output); | ||
|
||
for (int i = 0; i < this->numFiles; i++) { | ||
writeDataToFile(&files[i].data[0], files[i].size, files[i].filename, output); | ||
} | ||
} |
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,30 @@ | ||
#pragma once | ||
#include "../common/fileutil.h" | ||
|
||
#include <string> | ||
#include <fstream> | ||
|
||
struct DarEntry { | ||
std::string filename; | ||
uint32_t size; | ||
std::vector<uint8_t> data; | ||
}; | ||
|
||
struct DarHeader { | ||
int32_t numFiles; | ||
}; | ||
|
||
class Dar { | ||
public: | ||
Dar(std::string filename); | ||
~Dar(); | ||
|
||
void open(); | ||
int32_t getNumFiles(); | ||
void extract(std::string output = ""); | ||
std::vector<uint8_t> getFile(int32_t i); | ||
private: | ||
int32_t numFiles; | ||
std::vector<DarEntry> files; | ||
std::string filename = "cache.dar"; | ||
}; |
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,47 @@ | ||
#include "qar.h" | ||
|
||
Qar::Qar(std::string filename) { | ||
this->filename = filename; | ||
} | ||
|
||
Qar::~Qar() { | ||
|
||
} | ||
|
||
void Qar::open() { | ||
std::ifstream qarDat; | ||
qarDat.open(filename, std::ios::binary); | ||
|
||
qarDat.seekg(-4, qarDat.end); | ||
qarDat.read((char*)&header.offset, 4); | ||
|
||
qarDat.seekg(header.offset, qarDat.beg); | ||
qarDat.read((char*)&header.numFiles, 4); | ||
|
||
header.dataInfo.resize(header.numFiles); | ||
qarDat.read((char*)&header.dataInfo[0], header.numFiles * sizeof(QarDataInfo)); | ||
|
||
header.filenames.resize(header.numFiles); | ||
for (int i = 0; i < header.numFiles; i++) { | ||
std::getline(qarDat, header.filenames[i], '\0'); | ||
} | ||
|
||
qarDat.seekg(0, qarDat.beg); | ||
txpFiles.resize(header.numFiles); | ||
|
||
for (int i = 0; i < header.numFiles; i++) { | ||
int size = header.dataInfo[i].fileSize; | ||
txpFiles[i].resize(size); | ||
qarDat.read((char*)&txpFiles[i][0], size); | ||
} | ||
|
||
qarDat.close(); | ||
} | ||
|
||
void Qar::extract(std::string output) { | ||
updateDir("Qar", output); | ||
|
||
for (int i = 0; i < header.numFiles; i++) { | ||
writeDataToFile(&txpFiles[i][0], header.dataInfo[i].fileSize, header.filenames[i], output); | ||
} | ||
} |
Oops, something went wrong.