Andrew Jeffery | 812923d | 2018-02-22 11:59:52 +1030 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright (C) 2018 IBM Corp. |
| 3 | |
| 4 | #include "test/vpnor/tmpd.hpp" |
| 5 | |
| 6 | namespace openpower |
| 7 | { |
| 8 | namespace virtual_pnor |
| 9 | { |
| 10 | namespace test |
| 11 | { |
| 12 | |
| 13 | namespace fs = std::experimental::filesystem; |
| 14 | |
| 15 | size_t VpnorRoot::write(const std::string &name, const void *data, size_t len) |
| 16 | { |
| 17 | fs::path path{root}; |
| 18 | path /= name; |
| 19 | |
| 20 | if (!fs::exists(path)) |
| 21 | /* It's not in the ToC */ |
| 22 | throw std::invalid_argument(name); |
| 23 | |
| 24 | std::ofstream partitionFile(path.c_str()); |
| 25 | partitionFile.write((const char *)data, len); |
| 26 | partitionFile.close(); |
| 27 | |
| 28 | return len; |
| 29 | } |
| 30 | |
| 31 | } // test |
| 32 | } // virtual_pnor |
| 33 | } // openpower |