SDL: Add command-line CIA installs

This commit is contained in:
shinyquagsire23 2017-11-14 14:59:18 -07:00
parent 56e906f1e3
commit 553ca2bfe0

View File

@ -26,6 +26,7 @@
#include "citra/config.h" #include "citra/config.h"
#include "citra/emu_window/emu_window_sdl2.h" #include "citra/emu_window/emu_window_sdl2.h"
#include "common/file_util.h"
#include "common/logging/backend.h" #include "common/logging/backend.h"
#include "common/logging/filter.h" #include "common/logging/filter.h"
#include "common/logging/log.h" #include "common/logging/log.h"
@ -33,7 +34,9 @@
#include "common/scope_exit.h" #include "common/scope_exit.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "core/core.h" #include "core/core.h"
#include "core/file_sys/cia_container.h"
#include "core/gdbstub/gdbstub.h" #include "core/gdbstub/gdbstub.h"
#include "core/hle/service/am/am.h"
#include "core/loader/loader.h" #include "core/loader/loader.h"
#include "core/settings.h" #include "core/settings.h"
@ -41,6 +44,7 @@ static void PrintHelp(const char* argv0) {
std::cout << "Usage: " << argv0 std::cout << "Usage: " << argv0
<< " [options] <filename>\n" << " [options] <filename>\n"
"-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n" "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n"
"-i, --install=FILE Installs a specified CIA file\n"
"-h, --help Display this help and exit\n" "-h, --help Display this help and exit\n"
"-v, --version Output version information and exit\n"; "-v, --version Output version information and exit\n";
} }
@ -69,13 +73,14 @@ int main(int argc, char** argv) {
static struct option long_options[] = { static struct option long_options[] = {
{"gdbport", required_argument, 0, 'g'}, {"gdbport", required_argument, 0, 'g'},
{"install", required_argument, 0, 'i'},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'}, {"version", no_argument, 0, 'v'},
{0, 0, 0, 0}, {0, 0, 0, 0},
}; };
while (optind < argc) { while (optind < argc) {
char arg = getopt_long(argc, argv, "g:hv", long_options, &option_index); char arg = getopt_long(argc, argv, "g:i:hv", long_options, &option_index);
if (arg != -1) { if (arg != -1) {
switch (arg) { switch (arg) {
case 'g': case 'g':
@ -89,6 +94,16 @@ int main(int argc, char** argv) {
exit(1); exit(1);
} }
break; break;
case 'i': {
const auto cia_progress = [](size_t written, size_t total) {
LOG_INFO(Frontend, "%02zu%%", (written * 100 / total));
};
if (!Service::AM::InstallCIA(std::string(optarg), cia_progress))
errno = EINVAL;
if (errno != 0)
exit(1);
break;
}
case 'h': case 'h':
PrintHelp(argv[0]); PrintHelp(argv[0]);
return 0; return 0;