summaryrefslogtreecommitdiff
path: root/tools/nitrobanner/main.cpp
diff options
context:
space:
mode:
authorAkira Akashi <rubenru09@aol.com>2021-08-22 12:31:00 +0100
committerGitHub <noreply@github.com>2021-08-22 12:31:00 +0100
commit28b66f4e9efc2dbde3005f3e5bcc44b93ae47796 (patch)
tree6078bb064621ff03fbcb8ddec952eb05730c8e8c /tools/nitrobanner/main.cpp
parent97c8e77b2f951b6f0c43933576f21b833e7d5876 (diff)
parentd08722a7381c4c05a40ee59bb6de556616e1dfc2 (diff)
Merge branch 'master' into master
Diffstat (limited to 'tools/nitrobanner/main.cpp')
-rw-r--r--tools/nitrobanner/main.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/nitrobanner/main.cpp b/tools/nitrobanner/main.cpp
new file mode 100644
index 00000000..031d9218
--- /dev/null
+++ b/tools/nitrobanner/main.cpp
@@ -0,0 +1,45 @@
+#include <cstdio>
+#include <cstring>
+#include "banner.h"
+#include "types.h"
+
+#ifdef _MSC_VER
+#define strcasecmp _stricmp
+#endif
+
+int main(int argc, char* argv[]) {
+ if (argc != 2 && argc != 3) {
+ printf("usage: %s <specfile> [outfile]\n", argv[0]);
+ return 1;
+ }
+
+ const filesystem::path specfile_path = argv[1];
+ if (!filesystem::is_regular_file(specfile_path)) {
+ printf("error: provided specfile does not exist / is not a regular file. (did you put the right path?)\n");
+ return 1;
+ }
+
+ if (specfile_path.extension() == ".bnr") {
+ printf("error: can't use a bnr file as a specfile\n");
+ return 1;
+ }
+
+ // If the user doesn't provide a path to an outfile, or if the provided outfile is
+ // identical to the provided specfile, use the specfile's name + the .bnr extension.
+ filesystem::path outfile_path;
+ if (argc == 2 || strcasecmp(argv[1], argv[2]) == 0) {
+ outfile_path = specfile_path.stem().string() + ".bnr";
+ } else {
+ outfile_path = argv[2];
+ }
+
+ // printf("debug: specfile: %s\n", specfile_path.c_str());
+ // printf("debug: outfile: %s\n", outfile_path.c_str());
+
+ if (!MakeBanner(specfile_path, outfile_path)) {
+ printf("error: failed to create banner file\n");
+ return 1;
+ }
+
+ return 0;
+}