From 287f0a2ddfe715a3c9b6992c158852047bcd1e57 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 12 Jan 2016 01:04:39 +0100 Subject: Autoload files in solc. --- solc/CommandLineInterface.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'solc') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index fe760fdf..4c9de3c8 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -497,7 +497,18 @@ bool CommandLineInterface::processInput() return link(); } - m_compiler.reset(new CompilerStack(m_args.count(g_argAddStandard) > 0)); + function(string const&)> fileReader = [this](string const& _path) + { + auto path = boost::filesystem::path(_path); + if (!boost::filesystem::exists(path)) + return make_pair(string(), string("File not found.")); + else if (!boost::filesystem::is_regular_file(path)) + return make_pair(string(), string("Not a valid file.")); + else + return make_pair(m_sourceCodes[_path] = dev::contentsString(_path), string()); + }; + + m_compiler.reset(new CompilerStack(m_args.count(g_argAddStandard) > 0, fileReader)); try { for (auto const& sourceCode: m_sourceCodes) -- cgit