initial commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#include "sgu_stdafx.h"
|
||||
#include "sgu_mode_npk_dump_list.h"
|
||||
|
||||
#include "libNPK.h"
|
||||
|
||||
bool dumpNPKFileList(const char* inputFilename, const char* outputFilename)
|
||||
{
|
||||
if (!inputFilename || inputFilename[0] == 0)
|
||||
{
|
||||
printf("Error: Input filename is not specified.\n");
|
||||
return false;
|
||||
}
|
||||
if (!outputFilename || outputFilename[0] == 0)
|
||||
{
|
||||
printf("Error: Output filename is not specified.\n");
|
||||
return false;
|
||||
}
|
||||
NPK::INPKFile* pakFile = NPK::createNPKFile();
|
||||
if (!(pakFile->openPakFile(inputFilename)))
|
||||
{
|
||||
printf("Error: Failed to open NPK file: %s, ErrorCode:%d\n", inputFilename, NPK::getLastErrorCode());
|
||||
return false;
|
||||
}
|
||||
|
||||
FILE* fpOutput = fopen(outputFilename, "a+");
|
||||
if (!fpOutput)
|
||||
{
|
||||
printf("Error: Failed to open output file: %s\n", outputFilename);
|
||||
return false;
|
||||
}
|
||||
int32_t fileCount = pakFile->getFileCount();
|
||||
|
||||
// Dump file list
|
||||
for(int32_t i=0; i < fileCount; i++)
|
||||
{
|
||||
NPK::INPKFile::FileNode fileNode;
|
||||
if (!pakFile->getFileNode(i, fileNode))
|
||||
{
|
||||
printf("Error: Failed to get file node at index %d\n", i);
|
||||
fclose(fpOutput);
|
||||
return false;
|
||||
}
|
||||
NPK::IFileStream* fileStream = pakFile->openFileStream(fileNode.fileName.c_str());
|
||||
if (!fileStream)
|
||||
{
|
||||
printf("Error: Failed to open file stream for '%s', Error=%s\n", fileNode.fileName.c_str(), NPK::getLastErrorMessage());
|
||||
fclose(fpOutput);
|
||||
return false;
|
||||
}
|
||||
uint32_t crc32 = fileStream->crc32();
|
||||
fprintf(fpOutput, "%s\t%08x\t%u\n", fileNode.fileName.c_str(), crc32, fileNode.fileSize);
|
||||
|
||||
pakFile->closeFileStream(fileStream);
|
||||
}
|
||||
|
||||
fclose(fpOutput);
|
||||
|
||||
pakFile->closePakFile();
|
||||
NPK::closeNPKFile(pakFile);
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user