78 lines
1.4 KiB
C++
78 lines
1.4 KiB
C++
#include "CommandLineArgs.h"
|
|
|
|
#include "UnicodeUtils.h"
|
|
|
|
#include "Win32BaseIncludes.h"
|
|
|
|
CommandLineArgs::CommandLineArgs()
|
|
: mArugments(),
|
|
mLaunchPath()
|
|
{
|
|
|
|
}
|
|
|
|
void CommandLineArgs::initialize(CommandLineArgs* args)
|
|
{
|
|
#ifdef _WIN32
|
|
int nArgs{ 0 };
|
|
auto szArglist = ::CommandLineToArgvW(::GetCommandLineW(), &nArgs);
|
|
if (szArglist == nullptr)
|
|
{
|
|
return;
|
|
}
|
|
|
|
std::vector<std::string> windowsArgs(nArgs);
|
|
for (int idx = 0; idx < nArgs; idx++)
|
|
{
|
|
windowsArgs[idx] = UnicodeUtils::utf16ToUtf8String(szArglist[idx]);
|
|
}
|
|
::LocalFree(szArglist);
|
|
|
|
args->process(windowsArgs);
|
|
#else
|
|
(void)args;
|
|
#endif
|
|
}
|
|
|
|
Ptr<CommandLineArgs> CommandLineArgs::Create()
|
|
{
|
|
return Ptr<CommandLineArgs>::create();
|
|
}
|
|
|
|
FileSystemPath CommandLineArgs::getLaunchPath()
|
|
{
|
|
return mLaunchPath;
|
|
}
|
|
|
|
void CommandLineArgs::recordLaunchPath()
|
|
{
|
|
mLaunchPath = FileSystemPath::current_dir();
|
|
}
|
|
|
|
void CommandLineArgs::process(int argc, char *argv[])
|
|
{
|
|
for(int idx=0; idx<argc; idx++)
|
|
{
|
|
mArugments.push_back(String(argv[idx]));
|
|
}
|
|
}
|
|
|
|
void CommandLineArgs::process(const Vector<String>& args)
|
|
{
|
|
mArugments = args;
|
|
}
|
|
|
|
Vector<String> CommandLineArgs::getUserArgs() const
|
|
{
|
|
Vector<String> user_args;
|
|
for(unsigned idx=1; idx<mArugments.size(); idx++)
|
|
{
|
|
user_args.push_back(mArugments[idx]);
|
|
}
|
|
return user_args;
|
|
}
|
|
|
|
const Vector<String> CommandLineArgs::getArgs() const
|
|
{
|
|
return mArugments;
|
|
}
|