2015-06-30 06:46:19 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2015-07-04 06:02:12 +00:00
|
|
|
#include <LogVisor/LogVisor.hpp>
|
2015-07-02 18:33:55 +00:00
|
|
|
#include "NOD/NOD.hpp"
|
2015-06-30 06:46:19 +00:00
|
|
|
|
2015-06-30 19:38:51 +00:00
|
|
|
static void printHelp()
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Usage:\n"
|
|
|
|
" nodlib extract [-f] <image-in> [<dir-out>]\n"
|
|
|
|
" nodlib make <dir-in> [<image-out>]\n");
|
|
|
|
}
|
|
|
|
|
2015-07-02 20:37:07 +00:00
|
|
|
#if NOD_UCS2
|
|
|
|
#ifdef strcasecmp
|
|
|
|
#undef strcasecmp
|
|
|
|
#endif
|
|
|
|
#define strcasecmp _wcsicmp
|
|
|
|
int wmain(int argc, wchar_t* argv[])
|
|
|
|
#else
|
2015-06-30 06:46:19 +00:00
|
|
|
int main(int argc, char* argv[])
|
2015-07-02 20:37:07 +00:00
|
|
|
#endif
|
2015-06-30 06:46:19 +00:00
|
|
|
{
|
2015-06-30 19:38:51 +00:00
|
|
|
if (argc < 3)
|
2015-06-30 06:46:19 +00:00
|
|
|
{
|
2015-06-30 19:38:51 +00:00
|
|
|
printHelp();
|
2015-06-30 06:46:19 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-07-04 06:02:12 +00:00
|
|
|
/* Enable logging to console */
|
|
|
|
LogVisor::RegisterConsoleLogger();
|
|
|
|
|
2015-07-02 20:37:07 +00:00
|
|
|
const NOD::SystemChar* inDir = nullptr;
|
|
|
|
const NOD::SystemChar* outDir = _S(".");
|
2015-06-30 19:38:51 +00:00
|
|
|
bool force = false;
|
|
|
|
for (int a=2 ; a<argc ; ++a)
|
|
|
|
{
|
|
|
|
if (argv[a][0] == '-' && argv[a][1] == 'f')
|
|
|
|
force = true;
|
|
|
|
else if (!inDir)
|
|
|
|
inDir = argv[a];
|
|
|
|
else
|
|
|
|
outDir = argv[a];
|
|
|
|
}
|
2015-06-30 06:46:19 +00:00
|
|
|
|
2015-07-02 20:37:07 +00:00
|
|
|
if (!strcasecmp(argv[1], _S("extract")))
|
2015-06-30 19:38:51 +00:00
|
|
|
{
|
|
|
|
std::unique_ptr<NOD::DiscBase> disc = NOD::OpenDiscFromImage(inDir);
|
|
|
|
if (!disc)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
NOD::DiscBase::IPartition* dataPart = disc->getDataPartition();
|
|
|
|
if (!dataPart)
|
|
|
|
return -1;
|
2015-06-30 06:46:19 +00:00
|
|
|
|
2015-07-26 02:44:44 +00:00
|
|
|
if (!dataPart->extractToDirectory(outDir, force))
|
|
|
|
return -1;
|
2015-06-30 19:38:51 +00:00
|
|
|
}
|
2015-07-02 20:37:07 +00:00
|
|
|
else if (!strcasecmp(argv[1], _S("make")))
|
2015-06-30 06:46:19 +00:00
|
|
|
{
|
2015-06-30 19:38:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printHelp();
|
|
|
|
return -1;
|
2015-06-30 06:46:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|