FileReader: Store files loaded by the callback under their source unit name

This commit is contained in:
Kamil Śliwak
2021-04-13 13:25:59 +02:00
parent b9b483a0c3
commit 6a41b417a3
10 changed files with 113 additions and 3 deletions
+2 -3
View File
@@ -55,8 +55,7 @@ ReadCallback::Result FileReader::readFile(string const& _kind, string const& _pa
if (validPath.find("file://") == 0)
validPath.erase(0, 7);
auto const path = m_basePath / validPath;
auto canonicalPath = boost::filesystem::weakly_canonical(path);
auto canonicalPath = boost::filesystem::weakly_canonical(m_basePath / validPath);
bool isAllowed = false;
for (auto const& allowedDir: m_allowedDirectories)
{
@@ -81,7 +80,7 @@ ReadCallback::Result FileReader::readFile(string const& _kind, string const& _pa
// NOTE: we ignore the FileNotFound exception as we manually check above
auto contents = readFileAsString(canonicalPath.string());
m_sourceCodes[path.generic_string()] = contents;
m_sourceCodes[_path] = contents;
return ReadCallback::Result{true, contents};
}
catch (util::Exception const& _exception)