More string swapping and cleaning up main().
This commit is contained in:
@@ -10,16 +10,13 @@
|
||||
#include <xenia/xenia.h>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <poly/main.h>
|
||||
|
||||
using namespace xe;
|
||||
|
||||
DEFINE_string(target, "", "Specifies the target .xex or .iso to execute.");
|
||||
|
||||
DEFINE_string(target, "",
|
||||
"Specifies the target .xex or .iso to execute.");
|
||||
|
||||
|
||||
int xenia_run(int argc, xechar_t** argv) {
|
||||
int xenia_run(std::vector<std::wstring>& args) {
|
||||
int result_code = 1;
|
||||
|
||||
Profiler::Initialize();
|
||||
@@ -28,33 +25,28 @@ int xenia_run(int argc, xechar_t** argv) {
|
||||
Emulator* emulator = NULL;
|
||||
|
||||
// Grab path from the flag or unnamed argument.
|
||||
if (!FLAGS_target.size() && argc < 2) {
|
||||
if (!FLAGS_target.size() && args.size() < 2) {
|
||||
google::ShowUsageWithFlags("xenia-run");
|
||||
XEFATAL("Pass a file to launch.");
|
||||
return 1;
|
||||
}
|
||||
const xechar_t* path = NULL;
|
||||
std::wstring path;
|
||||
if (FLAGS_target.size()) {
|
||||
// Passed as a named argument.
|
||||
// TODO(benvanik): find something better than gflags that supports unicode.
|
||||
xechar_t buffer[poly::max_path];
|
||||
XEIGNORE(xestrwiden(buffer, sizeof(buffer), FLAGS_target.c_str()));
|
||||
path = buffer;
|
||||
path = poly::to_wstring(FLAGS_target);
|
||||
} else {
|
||||
// Passed as an unnamed argument.
|
||||
path = argv[1];
|
||||
path = args[1];
|
||||
}
|
||||
// Normalize the path and make absolute.
|
||||
std::wstring abs_path = poly::to_absolute_path(path);
|
||||
|
||||
// Create platform abstraction layer.
|
||||
xe_pal_options_t pal_options;
|
||||
xe_zero_struct(&pal_options, sizeof(pal_options));
|
||||
XEEXPECTZERO(xe_pal_init(pal_options));
|
||||
|
||||
// Normalize the path and make absolute.
|
||||
// TODO(benvanik): move this someplace common.
|
||||
xechar_t abs_path[poly::max_path];
|
||||
xe_path_get_absolute(path, abs_path, XECOUNT(abs_path));
|
||||
|
||||
// Create the emulator.
|
||||
emulator = new Emulator(L"");
|
||||
XEEXPECTNOTNULL(emulator);
|
||||
@@ -93,4 +85,5 @@ XECLEANUP:
|
||||
Profiler::Shutdown();
|
||||
return result_code;
|
||||
}
|
||||
XE_MAIN_WINDOW_THUNK(xenia_run, L"xenia-run", "xenia-run some.xex");
|
||||
|
||||
DEFINE_ENTRY_POINT(L"xenia-run", L"xenia-run some.xex", xenia_run);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'SubSystem': '2'
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
'dependencies': [
|
||||
|
||||
Reference in New Issue
Block a user