From 5eaf7c676d5d5a76ac10d2569aaba7c22ec3e6d3 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 29 Jun 2019 12:10:16 +0200 Subject: Improve dgvalidator usage and add man page for it. --- drumgizmo/dgvalidator.cc | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'drumgizmo') diff --git a/drumgizmo/dgvalidator.cc b/drumgizmo/dgvalidator.cc index d0cef8d..d7557aa 100644 --- a/drumgizmo/dgvalidator.cc +++ b/drumgizmo/dgvalidator.cc @@ -34,8 +34,32 @@ #include #include +void printUsage(const char* prog, bool full = true) +{ + printf("Usage: %s |-h|--help\n", prog); + if(!full) + { + return; + } + printf("Validates the xml and semantics of the drumkit file and prints " + "any found errors to the console.\n"); + printf("Returns 0 on success or 1 if errors were found.\n"); +} + int main(int argc, char* argv[]) { + if(argc != 2) + { + printUsage(argv[0], false); + return 1; + } + + if(std::string(argv[1]) == "-h" || std::string(argv[1]) == "--help") + { + printUsage(argv[0]); + return 1; + } + std::string edited_filename = argv[1]; DrumkitDOM drumkitdom; std::vector instrumentdoms; @@ -86,5 +110,20 @@ int main(int argc, char* argv[]) return 1; } - return 0; + // Verify all referred audiofiles + for(const auto& instrument: kit.instruments) + { + for(auto& audiofile: instrument->audiofiles) + { + audiofile->load(1); + if(!audiofile->isLoaded()) + { + WARN(drumkitloader, "Instrument file load error: '%s'", + audiofile->filename.data()); + parseerror = true; + } + } + } + + return parseerror ? 1 : 0; } -- cgit v1.2.3