mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
CommandLineInterface: Fix output directory creation for paths ending with a slash and equivalent but not equal to dot or double dot
This commit is contained in:
parent
f1846b57a2
commit
9f67d26a1a
@ -27,6 +27,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.
|
||||
|
||||
|
@ -730,12 +730,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