mirror of
https://github.com/AxioDL/nod.git
synced 2025-12-08 21:17:51 +00:00
working file extractor; removed hard-coded paths
This commit is contained in:
@@ -2,34 +2,53 @@
|
||||
#include <string.h>
|
||||
#include "NODLib.hpp"
|
||||
|
||||
static void printHelp()
|
||||
{
|
||||
fprintf(stderr, "Usage:\n"
|
||||
" nodlib extract [-f] <image-in> [<dir-out>]\n"
|
||||
" nodlib make <dir-in> [<image-out>]\n");
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc < 2)
|
||||
if (argc < 3)
|
||||
{
|
||||
fprintf(stderr, "Usage: nodlib <image-in>\n");
|
||||
printHelp();
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::unique_ptr<NOD::DiscBase> disc = NOD::OpenDiscFromImage(argv[1]);
|
||||
if (!disc)
|
||||
return -1;
|
||||
|
||||
disc->extractToDirectory("/home/jacko/Desktop/TrilogyDump2");
|
||||
|
||||
const NOD::DiscBase::IPartition* dataPart = disc->getDataPartition();
|
||||
if (dataPart)
|
||||
const char* inDir = nullptr;
|
||||
const char* outDir = ".";
|
||||
bool force = false;
|
||||
for (int a=2 ; a<argc ; ++a)
|
||||
{
|
||||
for (const NOD::DiscBase::IPartition::Node& node : dataPart->getFSTRoot())
|
||||
{
|
||||
if (node.getKind() == NOD::DiscBase::IPartition::Node::NODE_FILE)
|
||||
printf("FILE: %s\n", node.getName().c_str());
|
||||
else if (node.getKind() == NOD::DiscBase::IPartition::Node::NODE_DIRECTORY)
|
||||
{
|
||||
printf("DIR: %s\n", node.getName().c_str());
|
||||
for (const NOD::DiscBase::IPartition::Node& subnode : node)
|
||||
printf("SUBFILE: %s\n", subnode.getName().c_str());
|
||||
}
|
||||
}
|
||||
if (argv[a][0] == '-' && argv[a][1] == 'f')
|
||||
force = true;
|
||||
else if (!inDir)
|
||||
inDir = argv[a];
|
||||
else
|
||||
outDir = argv[a];
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[1], "extract"))
|
||||
{
|
||||
std::unique_ptr<NOD::DiscBase> disc = NOD::OpenDiscFromImage(inDir);
|
||||
if (!disc)
|
||||
return -1;
|
||||
|
||||
NOD::DiscBase::IPartition* dataPart = disc->getDataPartition();
|
||||
if (!dataPart)
|
||||
return -1;
|
||||
|
||||
dataPart->extractToDirectory(outDir, force);
|
||||
}
|
||||
else if (!strcasecmp(argv[1], "make"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
printHelp();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user