aboutsummaryrefslogtreecommitdiffstats
path: root/solc/CommandLineInterface.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-03-11 02:11:01 +0800
committerchriseth <c@ethdev.com>2017-03-11 02:23:43 +0800
commit31a5e5bfef086c1cac477661dd627fa774bc44f5 (patch)
tree9a4fb8b2a8a4b65a6c4270ce6418fef2466710a2 /solc/CommandLineInterface.cpp
parent864bfafbcd77846b688ece3edb945a285b74c747 (diff)
downloaddexon-solidity-31a5e5bfef086c1cac477661dd627fa774bc44f5.tar
dexon-solidity-31a5e5bfef086c1cac477661dd627fa774bc44f5.tar.gz
dexon-solidity-31a5e5bfef086c1cac477661dd627fa774bc44f5.tar.bz2
dexon-solidity-31a5e5bfef086c1cac477661dd627fa774bc44f5.tar.lz
dexon-solidity-31a5e5bfef086c1cac477661dd627fa774bc44f5.tar.xz
dexon-solidity-31a5e5bfef086c1cac477661dd627fa774bc44f5.tar.zst
dexon-solidity-31a5e5bfef086c1cac477661dd627fa774bc44f5.zip
Do not overwrite files unless forced.
Diffstat (limited to 'solc/CommandLineInterface.cpp')
-rw-r--r--solc/CommandLineInterface.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index 6759727f..0c777c77 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -93,6 +93,7 @@ static string const g_strOpcodes = "opcodes";
static string const g_strOptimize = "optimize";
static string const g_strOptimizeRuns = "optimize-runs";
static string const g_strOutputDir = "output-dir";
+static string const g_strOverwrite = "overwrite";
static string const g_strSignatureHashes = "hashes";
static string const g_strSources = "sources";
static string const g_strSourceList = "sourceList";
@@ -465,6 +466,12 @@ void CommandLineInterface::createFile(string const& _fileName, string const& _da
if (p.filename() != "." && p.filename() != "..")
fs::create_directories(p);
string pathName = (p / _fileName).string();
+ if (fs::exists(pathName) && !m_args.count(g_strOverwrite))
+ {
+ cerr << "Refusing to overwrite existing file \"" << pathName << "\" (use --overwrite to force)." << endl;
+ m_error = true;
+ return;
+ }
ofstream outFile(pathName);
outFile << _data;
if (!outFile)
@@ -510,6 +517,7 @@ Allowed options)",
po::value<string>()->value_name("path"),
"If given, creates one file per component and contract/file at the specified directory."
)
+ (g_strOverwrite.c_str(), "Overwrite existing files (used together with -o).")
(
g_argCombinedJson.c_str(),
po::value<string>()->value_name(boost::join(g_combinedJsonArgs, ",")),
@@ -858,7 +866,7 @@ void CommandLineInterface::handleAst(string const& _argStr)
}
}
-void CommandLineInterface::actOnInput()
+bool CommandLineInterface::actOnInput()
{
if (m_onlyAssemble)
outputAssembly();
@@ -866,6 +874,7 @@ void CommandLineInterface::actOnInput()
writeLinkedFiles();
else
outputCompilationResults();
+ return !m_error;
}
bool CommandLineInterface::link()