diff options
author | chriseth <chris@ethereum.org> | 2017-10-19 19:39:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-19 19:39:28 +0800 |
commit | b96602122c2380b1759a8f657a9b97e30c5978b0 (patch) | |
tree | 5f7274239b911ecb08e7dcfbef66780620de7231 /libdevcore/CommonIO.cpp | |
parent | 892c3ef8efeb3a79c9e11722651f430f392071c6 (diff) | |
parent | 6f2865228cb02f0ba0b58990a9d3006dbe2692c6 (diff) | |
download | dexon-solidity-b96602122c2380b1759a8f657a9b97e30c5978b0.tar dexon-solidity-b96602122c2380b1759a8f657a9b97e30c5978b0.tar.gz dexon-solidity-b96602122c2380b1759a8f657a9b97e30c5978b0.tar.bz2 dexon-solidity-b96602122c2380b1759a8f657a9b97e30c5978b0.tar.lz dexon-solidity-b96602122c2380b1759a8f657a9b97e30c5978b0.tar.xz dexon-solidity-b96602122c2380b1759a8f657a9b97e30c5978b0.tar.zst dexon-solidity-b96602122c2380b1759a8f657a9b97e30c5978b0.zip |
Merge pull request #3098 from ethereum/cli-cleanup
Cleanup some file/io reader in devcore
Diffstat (limited to 'libdevcore/CommonIO.cpp')
-rw-r--r-- | libdevcore/CommonIO.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index 5d47937b..8c7e08f6 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -39,7 +39,7 @@ namespace { template <typename _T> -inline _T contentsGeneric(std::string const& _file) +inline _T readFile(std::string const& _file) { _T ret; size_t const c_elementSize = sizeof(typename _T::value_type); @@ -61,9 +61,23 @@ inline _T contentsGeneric(std::string const& _file) } -string dev::contentsString(string const& _file) +string dev::readFileAsString(string const& _file) { - return contentsGeneric<string>(_file); + return readFile<string>(_file); +} + +string dev::readStandardInput() +{ + string ret; + while (!cin.eof()) + { + string tmp; + // NOTE: this will read until EOF or NL + getline(cin, tmp); + ret.append(tmp); + ret.append("\n"); + } + return ret; } void dev::writeFile(std::string const& _file, bytesConstRef _data, bool _writeDeleteRename) |