MCPcopy Create free account
hub / github.com/LUX-Core/lux / writeFile

Method writeFile

src/cpp-ethereum/libdevcore/CommonIO.cpp:107–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107void dev::writeFile(std::string const& _file, bytesConstRef _data, bool _writeDeleteRename)
108{
109 namespace fs = boost::filesystem;
110 if (_writeDeleteRename)
111 {
112 fs::path tempPath = fs::unique_path(_file + "-%%%%%%");
113 writeFile(tempPath.string(), _data, false);
114 // will delete _file if it exists
115 fs::rename(tempPath, _file);
116 }
117 else
118 {
119 // create directory if not existent
120 fs::path p(_file);
121 if (!fs::exists(p.parent_path()))
122 {
123 fs::create_directories(p.parent_path());
124 DEV_IGNORE_EXCEPTIONS(fs::permissions(p.parent_path(), fs::owner_all));
125 }
126
127 ofstream s(_file, ios::trunc | ios::binary);
128 s.write(reinterpret_cast<char const*>(_data.data()), _data.size());
129 if (!s)
130 BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + _file));
131 DEV_IGNORE_EXCEPTIONS(fs::permissions(_file, fs::owner_read|fs::owner_write));
132 }
133}
134
135std::string dev::getPassword(std::string const& _prompt)
136{

Callers

nothing calls this directly

Calls 4

writeFileFunction · 0.85
writeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected