Merge pull request #3830 from ethereum/fix-include-paths-errors

Fix include paths errors
This commit is contained in:
Daniel Kirchner 2018-04-11 21:25:30 +02:00 committed by GitHub
commit 8d355df14c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 9 deletions

View File

@ -26,6 +26,7 @@ Bugfixes:
* Code Generator: Bugfix in modifier lookup in libraries.
* Code Generator: Implement packed encoding of external function types.
* Code Generator: Treat empty base constructor argument list as not provided.
* Commandline interface: Fix error messages for imported files that do not exist.
* Commandline interface: Support ``--evm-version constantinople`` properly.
* DocString Parser: Fix error message for empty descriptions.
* Standard JSON: Support ``constantinople`` as ``evmVersion`` properly.

View File

@ -167,3 +167,23 @@ int dev::readStandardInputChar()
DisableConsoleBuffering disableConsoleBuffering;
return cin.get();
}
boost::filesystem::path dev::weaklyCanonicalFilesystemPath(boost::filesystem::path const &_path)
{
if (boost::filesystem::exists(_path))
return boost::filesystem::canonical(_path);
else
{
boost::filesystem::path head(_path);
boost::filesystem::path tail;
for (auto it = --_path.end(); !head.empty(); --it)
{
if (boost::filesystem::exists(head))
break;
tail = (*it) / tail;
head.remove_filename();
}
head = boost::filesystem::canonical(head);
return head / tail;
}
}

View File

@ -25,6 +25,7 @@
#include <sstream>
#include <string>
#include <boost/filesystem.hpp>
#include "Common.h"
namespace dev
@ -57,4 +58,8 @@ std::string toString(_T const& _t)
return o.str();
}
/// Partial implementation of boost::filesystem::weakly_canonical (available in boost>=1.60).
/// Should be replaced by the boost implementation as soon as support for boost<1.60 can be dropped.
boost::filesystem::path weaklyCanonicalFilesystemPath(boost::filesystem::path const &_path);
}

View File

@ -700,7 +700,7 @@ bool CommandLineInterface::processInput()
try
{
auto path = boost::filesystem::path(_path);
auto canonicalPath = boost::filesystem::canonical(path);
auto canonicalPath = weaklyCanonicalFilesystemPath(path);
bool isAllowed = false;
for (auto const& allowedDir: m_allowedDirectories)
{
@ -716,16 +716,16 @@ bool CommandLineInterface::processInput()
}
if (!isAllowed)
return ReadCallback::Result{false, "File outside of allowed directories."};
else if (!boost::filesystem::exists(path))
if (!boost::filesystem::exists(canonicalPath))
return ReadCallback::Result{false, "File not found."};
else if (!boost::filesystem::is_regular_file(canonicalPath))
if (!boost::filesystem::is_regular_file(canonicalPath))
return ReadCallback::Result{false, "Not a valid file."};
else
{
auto contents = dev::readFileAsString(canonicalPath.string());
m_sourceCodes[path.string()] = contents;
return ReadCallback::Result{true, contents};
}
auto contents = dev::readFileAsString(canonicalPath.string());
m_sourceCodes[path.string()] = contents;
return ReadCallback::Result{true, contents};
}
catch (Exception const& _exception)
{