+ if (!strcmp(argv[0]+1, "debug")) {
+ OPTS_OPTION_BOOL(OPTION_DEBUG) = true;
+ continue;
+ }
+ if (!strcmp(argv[0]+1, "memchk")) {
+ OPTS_OPTION_BOOL(OPTION_MEMCHK) = true;
+ continue;
+ }
+ if (!strcmp(argv[0]+1, "nocolor")) {
+ con_color(0);
+ continue;
+ }
+ }
+
+ vec_push(files, argv[0]);
+ }
+ con_change(redirout, redirerr);
+
+
+ if (!file) {
+ con_err("-file must be specified for output/input PAK file\n");
+ vec_free(files);
+ return EXIT_FAILURE;
+ }
+
+ if (extract) {
+ if (!(pak = pak_open(file, "r"))) {
+ con_err("failed to open PAK file %s\n", file);
+ vec_free(files);
+ return EXIT_FAILURE;
+ }
+
+ if (!pak_extract_all(pak, "./")) {
+ con_err("failed to extract PAK %s (files may be missing)\n", file);
+ pak_close(pak);
+ vec_free(files);
+ return EXIT_FAILURE;
+ }
+
+ /* not possible */
+ pak_close(pak);
+ vec_free(files);
+ util_meminfo();
+ return EXIT_SUCCESS;
+ }
+
+ if (!(pak = pak_open(file, "w"))) {
+ con_err("failed to open PAK %s for writing\n", file);
+ vec_free(files);
+ return EXIT_FAILURE;
+ }
+
+ for (iter = 0; iter < vec_size(files); iter++) {
+ if (!(pak_insert_one(pak, files[iter]))) {
+ con_err("failed inserting %s for PAK %s\n", files[iter], file);
+ pak_close(pak);
+ vec_free(files);
+ return EXIT_FAILURE;
+ }
+ }
+
+ /* not possible */