87 lines
2.3 KiB
C++
87 lines
2.3 KiB
C++
/**
|
|
* @file RDIdebug.cpp
|
|
* @date 17/09/2022
|
|
* @author JackCarterSmith
|
|
* @copyright GPL-v3.0
|
|
* @brief Debug app to test functions of RDI library.
|
|
*
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <boost/filesystem.hpp>
|
|
#include <RDI.hpp>
|
|
|
|
|
|
void PrintVirtualDirectoryContents( boost::filesystem::path, std::string );
|
|
|
|
int main( int argc, char *argv[] ) {
|
|
unsigned int i;
|
|
boost::filesystem::path pathBuilder;
|
|
std::string prefix;
|
|
|
|
printf("Using RDI lib v%s\n\n", RDI::getLibVersion().c_str());
|
|
//cout << "Using RDI lib v" << RDI::getLibVersion() << endl << endl;
|
|
|
|
if ( argc > 1 )
|
|
RDI::CreateRDatHandler(argv[1]);
|
|
else
|
|
RDI::CreateRDatHandler(".");
|
|
|
|
printf("> Section found: %d\n", RDI::getSectionCount());
|
|
for ( i = 0; i < RDI::getSectionCount(); i++ ) {
|
|
printf(" -Section %d name: %s\n", i, RDI::getSectionName(i).c_str());
|
|
printf(" -Section %d offset: 0x%X\n", i, RDI::getSectionOffset(i));
|
|
}
|
|
|
|
//prefix.append("\t");
|
|
prefix.append(" ");
|
|
printf("\nSections files root:\n");
|
|
for ( i = 0; i < RDI::getSectionCount(); i++ ) {
|
|
printf("%s:\n", RDI::getSectionName(i).c_str()); // Print root trees
|
|
|
|
pathBuilder.clear();
|
|
pathBuilder.concat(RDI::getSectionName(i));
|
|
|
|
PrintVirtualDirectoryContents(pathBuilder, prefix);
|
|
}
|
|
|
|
RDI::CreateLegacyHandler();
|
|
for ( std::string lname : RDI::getLevelsName() ) {
|
|
printf("Level found: %s\n", lname.c_str());
|
|
}
|
|
for ( std::string mdname : RDI::getModelsName() ) {
|
|
printf("Model found: %s\n", mdname.c_str());
|
|
}
|
|
for ( std::string mname : RDI::getMusicsName() ) {
|
|
printf("Music found: %s\n", mname.c_str());
|
|
}
|
|
|
|
RDI::DestroyRDatHandler();
|
|
|
|
return 0;
|
|
}
|
|
|
|
void PrintVirtualDirectoryContents( boost::filesystem::path path, std::string outPrefix ) {
|
|
auto curDirElementsName = RDI::getDirectoryElements(path.string());
|
|
auto newPath = boost::filesystem::path(path);
|
|
auto newOutPrefix = std::string(outPrefix);
|
|
|
|
for ( std::string eName : curDirElementsName ) {
|
|
newPath.clear();
|
|
newPath.concat(path);
|
|
newOutPrefix.clear();
|
|
newOutPrefix.append(outPrefix);
|
|
|
|
newPath.append(eName);
|
|
if (RDI::isElementDirectory(newPath.string())) {
|
|
printf("%s%s:\n", outPrefix.c_str(), eName.c_str());
|
|
//newOutPrefix.append("\t");
|
|
newOutPrefix.append(" ");
|
|
PrintVirtualDirectoryContents(newPath, newOutPrefix);
|
|
} else {
|
|
printf("%s%s\n", newOutPrefix.c_str(), eName.c_str());
|
|
}
|
|
}
|
|
}
|