diff options
author | deva <deva> | 2008-12-21 19:24:29 +0000 |
---|---|---|
committer | deva <deva> | 2008-12-21 19:24:29 +0000 |
commit | 5dcfbc8bd840dfd60573e038194a43b37ebfc047 (patch) | |
tree | 477b760b574a455441f6586123ff5adef6036c95 /src/drumkitparser.cc | |
parent | 90d1466d82e01fd7e5e2d2b49977e2dccaac9e33 (diff) |
Added some cli options. Made preload optional on the commandline. Made chdir to drumkit file prior to loading of the samples.
Diffstat (limited to 'src/drumkitparser.cc')
-rw-r--r-- | src/drumkitparser.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc index 14e4a88..3f16dd2 100644 --- a/src/drumkitparser.cc +++ b/src/drumkitparser.cc @@ -26,10 +26,28 @@ */ #include "drumkitparser.h" -DrumKitParser::DrumKitParser(char *file) +#define DIR_SEPERATOR '/' + +DrumKitParser::DrumKitParser(std::string kitfile, bool preload) { + std::string file; + std::string path; + + char *split = strrchr(kitfile.c_str(), DIR_SEPERATOR); + if(split) { + file = split + 1; + split = '\0'; + path = kitfile.substr(0, kitfile.length() - file.length()); + // All drum samples are relative to the kitfile, so we must chdir there to be able to open them. + chdir(path.c_str()); + } else { + file = kitfile; + } + + this->preload = preload; + dk = NULL; - fd = fopen(file, "r"); + fd = fopen(file.c_str(), "r"); if(!fd) return; dk = new DrumKit(); } @@ -62,7 +80,7 @@ void DrumKitParser::startTag(std::string name, std::map< std::string, std::strin } if(name == "audiofile") { - AudioFile *af = new AudioFile(attributes["name"]); + AudioFile *af = new AudioFile(attributes["name"], preload); af->channel = attributes["channel"]; lastsample->audiofiles[attributes["name"]] = af; } |