Fixed extraction issues with root windows paths

This commit is contained in:
Jack Andersen 2015-09-10 10:44:25 -10:00
parent 69b5c4513f
commit 3941580275
6 changed files with 38 additions and 14 deletions

View File

@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <list>
#include <stdio.h>
#include <string.h>
@ -19,7 +20,7 @@ struct ToolPassInfo
{
HECL::SystemString pname;
HECL::SystemString cwd;
std::vector<HECL::SystemString> args;
std::list<HECL::SystemString> args;
HECL::SystemString output;
HECL::Database::Project* project = NULL;
unsigned verbosityLevel = 0;

View File

@ -36,7 +36,7 @@ public:
if (!info.project)
{
/* Get name from input file and init project there */
HECL::SystemString baseFile = info.args[0];
HECL::SystemString baseFile = info.args.front();
size_t slashPos = baseFile.rfind(_S('/'));
if (slashPos == HECL::SystemString::npos)
slashPos = baseFile.rfind(_S('\\'));
@ -50,7 +50,7 @@ public:
LogModule.report(LogVisor::FatalError, "hecl extract must be ran within a project directory");
size_t ErrorRef = LogVisor::ErrorCount;
HECL::SystemString rootDir = info.cwd + _S('/') + baseFile;
HECL::SystemString rootDir = info.cwd + baseFile;
HECL::ProjectRootPath newProjRoot(rootDir);
newProjRoot.makeDir();
m_fallbackProj.reset(new HECL::Database::Project(newProjRoot));
@ -62,11 +62,12 @@ public:
else
m_useProj = info.project;
m_einfo.srcpath = m_info.args[0];
m_einfo.srcpath = m_info.args.front();
m_einfo.extractArgs.reserve(info.args.size() - 1);
m_einfo.force = info.force;
for (std::vector<HECL::SystemString>::const_iterator it=info.args.begin() + 1;
it != info.args.end();
std::list<HECL::SystemString>::const_iterator it=info.args.begin();
++it;
for (;it != info.args.end();
++it)
m_einfo.extractArgs.push_back(*it);

View File

@ -94,7 +94,7 @@ public:
int run()
{
ShowHelp(m_info.args[0]);
ShowHelp(m_info.args.front());
return 0;
}
};

View File

@ -14,7 +14,7 @@ public:
HECL::Sstat theStat;
const HECL::SystemString* dir;
if (info.args.size())
dir = &info.args[0];
dir = &info.args.front();
else
dir = &info.cwd;

View File

@ -25,7 +25,7 @@ public:
"hecl spec must be ran within a project directory");
const auto& specs = info.project->getDataSpecs();
HECL::SystemString firstArg = info.args[0];
HECL::SystemString firstArg = info.args.front();
HECL::ToLower(firstArg);
static const HECL::SystemString enable(_S("enable"));
@ -40,8 +40,9 @@ public:
if (info.args.size() < 2)
LogModule.report(LogVisor::FatalError, "Speclist argument required");
for (auto it = info.args.begin()+1;
it != info.args.end();
auto it = info.args.begin();
++it;
for (;it != info.args.end();
++it)
{
@ -126,8 +127,9 @@ public:
}
std::vector<HECL::SystemString> opSpecs;
for (auto it = m_info.args.begin()+1;
it != m_info.args.end();
auto it = m_info.args.begin();
++it;
for (;it != m_info.args.end();
++it)
{
HECL::SystemString itName = *it;

View File

@ -138,7 +138,15 @@ int main(int argc, const char** argv)
info.pname = argv[0];
HECL::SystemChar cwdbuf[1024];
if (HECL::Getcwd(cwdbuf, 1024))
{
info.cwd = cwdbuf;
if (info.cwd.size() && info.cwd.back() != _S('/') && info.cwd.back() != _S('\\'))
#if _WIN32
info.cwd += _S('\\');
#else
info.cwd += _S('/');
#endif
}
/* Concatenate args */
std::list<HECL::SystemString> args;
@ -254,7 +262,19 @@ int main(int argc, const char** argv)
else if (toolName == _S("help"))
tool.reset(new ToolHelp(info));
else
LogModule.report(LogVisor::Error, _S("unrecognized tool '%s'"), toolName.c_str());
{
FILE* fp = HECL::Fopen(argv[1], _S("rb"));
if (!fp)
LogModule.report(LogVisor::Error, _S("unrecognized tool '%s'"), toolName.c_str());
else
{
/* Shortcut-case: implicit extract */
fclose(fp);
info.args.push_front(argv[1]);
tool.reset(new ToolExtract(info));
}
}
if (LogVisor::ErrorCount > ErrorRef)
{
#if WIN_PAUSE