mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10293 from ethereum/fix-output-dir-creation-with-trailing-slash
[CLI] Fix --output-dir failure for paths with a trailing slash
This commit is contained in:
commit
a97521bff1
@ -28,6 +28,7 @@ Bugfixes:
|
||||
* SMTChecker: Fix false negative in modifier applied multiple times.
|
||||
* SMTChecker: Fix internal error in the BMC engine when inherited contract from a different source unit has private state variables.
|
||||
* SMTChecker: Fix internal error when ``array.push()`` is used as the LHS of an assignment.
|
||||
* Command Line Interface: Fix write error when the directory passed to ``--output-dir`` ends with a slash.
|
||||
* SMTChecker: Fix CHC false positives when branches are used inside modifiers.
|
||||
* Code generator: Fix missing creation dependency tracking for abstract contracts.
|
||||
|
||||
|
@ -737,12 +737,15 @@ map<string, Json::Value> CommandLineInterface::parseAstFromInput()
|
||||
void CommandLineInterface::createFile(string const& _fileName, string const& _data)
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
// create directory if not existent
|
||||
fs::path p(m_args.at(g_argOutputDir).as<string>());
|
||||
// Do not try creating the directory if the first item is . or ..
|
||||
if (p.filename() != "." && p.filename() != "..")
|
||||
fs::create_directories(p);
|
||||
string pathName = (p / _fileName).string();
|
||||
|
||||
fs::path outputDir(m_args.at(g_argOutputDir).as<string>());
|
||||
|
||||
// NOTE: create_directories() raises an exception if the path consists solely of '.' or '..'
|
||||
// (or equivalent such as './././.'). Paths like 'a/b/.' and 'a/b/..' are fine though.
|
||||
// The simplest workaround is to use an absolute path.
|
||||
fs::create_directories(fs::absolute(outputDir));
|
||||
|
||||
string pathName = (outputDir / _fileName).string();
|
||||
if (fs::exists(pathName) && !m_args.count(g_strOverwrite))
|
||||
{
|
||||
serr() << "Refusing to overwrite existing file \"" << pathName << "\" (use --" << g_strOverwrite << " to force)." << endl;
|
||||
|
Loading…
Reference in New Issue
Block a user