Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/Bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,40 @@ const std::string& Bundle::getDataDirectory()
return selectedBundle().dataDir;
}


template <typename Out>
void split(const std::string &s, char delim, Out result) {
std::istringstream iss(s);
std::string item;
while (std::getline(iss, item, delim)) {
*result++ = item;
}
}

std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
split(s, delim, std::back_inserter(elems));
return elems;
}

std::string Bundle::findFileByName(const std::string& relativePath)
{
if (relativePath.empty())
throw std::runtime_error("The path to the file is empty. relativePath = " + relativePath);

LOG_DEBUG_S << "relativePath = " << relativePath << std::endl;
// remove any arguments, e.g. from syscall template
std::vector<std::string> split_str = split(relativePath, ' ');
const std::string& relPath = split_str.at(0);
LOG_DEBUG_S << "relPath = " << relPath << std::endl;
for(const SingleBundle &bundle : activeBundles)
{
fs::path curPath = fs::path(bundle.path) / relativePath;
fs::path curPath = fs::path(bundle.path) / relPath;
fs::path fullPath = fs::path(bundle.path) / relativePath;
if(boost::filesystem::exists(curPath))
return curPath.string();
return fullPath.string();
}
throw std::runtime_error("Could not find file " + relativePath);
throw std::runtime_error("Could not find file. relativePath = " + relativePath + ", relPath = " + relPath);
}

std::vector<std::string> Bundle::findFilesByName(const std::string& relativePath)
Expand Down