Skip to content

Commit

Permalink
Allow specifying output path
Browse files Browse the repository at this point in the history
  • Loading branch information
Torphedo committed Jan 15, 2024
1 parent 2373ce0 commit f8b2a5b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
12 changes: 11 additions & 1 deletion alr/src/arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ flags parse_arguments(int argc, char** argv) {
// Check if first 2 characters are "--"
if (argv[i][0] != '-' || argv[i][1] != '-') {
// If it's not a flag, it must be a filename
output.filename = argv[i];
if (output.input_path != NULL) {
if (output.output_path != NULL) {
output.input_path = output.output_path;
}
output.output_path = argv[i];
}
else {
output.input_path = argv[i];
}


continue;
}

Expand Down
3 changes: 2 additions & 1 deletion alr/src/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ typedef enum {
}program_mode;

typedef struct {
char* filename;
char* input_path;
char* output_path;
program_mode mode;
bool silent;
}flags;
Expand Down
14 changes: 9 additions & 5 deletions alr/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ int main(int argc, char* argv[]) {
// Parse command-line arguments.
flags options = parse_arguments(argc, argv);

if (options.filename == NULL) {
LOG_MSG(error, "No filenames detected.\n");
if (options.input_path == NULL) {
LOG_MSG(error, "No ALR to operate on, exiting\n");
return 1;
}

if (options.silent) {
disable_logging();
}

// Default to dump behaviour if nothing is specified. No arguments probably
// means someone drag-and-dropped, which means they probably want textures.
alr_interface interface = dump_interface;
Expand All @@ -39,13 +39,17 @@ int main(int argc, char* argv[]) {
LOG_MSG(error, "Unimplemented program mode, exiting.\n");
return 1;
case replacetex:
return !(alr_edit(options.filename, "out.alr", options, replace_interface));
if (options.output_path == NULL) {
LOG_MSG(error, "No output file provided.\n");
return 1;
}
return !(alr_edit(options.input_path, options.output_path, options, replace_interface));
break;
}

// Parse ALR with selected interface.
// Return value must be inverted because stdbool false == 0, and an exit
// code of 0 means success.
return !(alr_parse(options.filename, options, interface));
return !(alr_parse(options.input_path, options, interface));
}

1 change: 0 additions & 1 deletion alr/src/replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "int_shorthands.h"
#include "filesystem.h"
#include "alr.h"

// Size of DDS header and pixel format header
#define DDS_HEADER_SIZE (0x7F)
Expand Down

0 comments on commit f8b2a5b

Please sign in to comment.