--- linuxsampler/trunk/src/engines/sfz/sfz.cpp 2014/03/03 12:02:40 2528 +++ linuxsampler/trunk/src/engines/sfz/sfz.cpp 2014/03/04 20:41:47 2529 @@ -874,6 +874,11 @@ _instrument = new Instrument(LinuxSampler::Path::getBaseName(file), pSampleManager); _current_group = new Group(); pCurDef = _current_group; + + parseFile(file,pSampleManager); + } + + void File::parseFile(std::string file, SampleManager* pSampleManager){ enum token_type_t { HEADER, OPCODE }; token_type_t token_type; std::string token_string; @@ -892,6 +897,25 @@ if (slash_index != std::string::npos) line.resize(slash_index); + // #include + if (line.find("#include ") == 0) { + size_t fname_start = line.find("\""); + if (fname_start == std::string::npos) continue; + + size_t fname_end = line.find("\"", fname_start + 1); + if (fname_end == std::string::npos || fname_start == fname_end) + continue; + std::string fname = line.substr(fname_start + 1, fname_end - fname_start - 1); + + if (!currentDir.empty() && !LinuxSampler::Path(fname).isAbsolute()) + fname = currentDir + LinuxSampler::File::DirSeparator + fname; + + std::string cd = currentDir; // backup current dir + parseFile(fname, pSampleManager); + currentDir = cd; // restore currentDir (since altered by parsefile()) + continue; + } + // DEFINITION std::stringstream linestream(line); int spaces = 0;