mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Pull out ReadFile from CompilerStack
This commit is contained in:
@@ -630,11 +630,11 @@ bool CommandLineInterface::processInput()
|
||||
return link();
|
||||
}
|
||||
|
||||
CompilerStack::ReadFileCallback fileReader = [this](string const& _path)
|
||||
ReadFile::Callback fileReader = [this](string const& _path)
|
||||
{
|
||||
auto path = boost::filesystem::path(_path);
|
||||
if (!boost::filesystem::exists(path))
|
||||
return CompilerStack::ReadFileResult{false, "File not found."};
|
||||
return ReadFile::Result{false, "File not found."};
|
||||
auto canonicalPath = boost::filesystem::canonical(path);
|
||||
bool isAllowed = false;
|
||||
for (auto const& allowedDir: m_allowedDirectories)
|
||||
@@ -650,14 +650,14 @@ bool CommandLineInterface::processInput()
|
||||
}
|
||||
}
|
||||
if (!isAllowed)
|
||||
return CompilerStack::ReadFileResult{false, "File outside of allowed directories."};
|
||||
return ReadFile::Result{false, "File outside of allowed directories."};
|
||||
else if (!boost::filesystem::is_regular_file(canonicalPath))
|
||||
return CompilerStack::ReadFileResult{false, "Not a valid file."};
|
||||
return ReadFile::Result{false, "Not a valid file."};
|
||||
else
|
||||
{
|
||||
auto contents = dev::contentsString(canonicalPath.string());
|
||||
m_sourceCodes[path.string()] = contents;
|
||||
return CompilerStack::ReadFileResult{true, contents};
|
||||
return ReadFile::Result{true, contents};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
|
||||
{
|
||||
Json::Value output(Json::objectValue);
|
||||
Json::Value errors(Json::arrayValue);
|
||||
CompilerStack::ReadFileCallback readCallback;
|
||||
ReadFile::Callback readCallback;
|
||||
if (_readCallback)
|
||||
{
|
||||
readCallback = [=](string const& _path)
|
||||
@@ -138,7 +138,7 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
|
||||
char* contents_c = nullptr;
|
||||
char* error_c = nullptr;
|
||||
_readCallback(_path.c_str(), &contents_c, &error_c);
|
||||
CompilerStack::ReadFileResult result;
|
||||
ReadFile::Result result;
|
||||
result.success = true;
|
||||
if (!contents_c && !error_c)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user