blob: 6bdfa090b61f63ac68fe61e0f2b244ec4a2815f3 [file] [log] [blame]
Andrew Jeffery812923d2018-02-22 11:59:52 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
3
4#include "test/vpnor/tmpd.hpp"
5
6namespace openpower
7{
8namespace virtual_pnor
9{
10namespace test
11{
12
13namespace fs = std::experimental::filesystem;
14
15size_t VpnorRoot::write(const std::string &name, const void *data, size_t len)
16{
Andrew Jeffery097495c2018-02-22 11:36:13 +103017 // write() is for test environment setup - always write to ro section
18 fs::path path = root / "ro" / name;
Andrew Jeffery812923d2018-02-22 11:59:52 +103019
20 if (!fs::exists(path))
21 /* It's not in the ToC */
22 throw std::invalid_argument(name);
23
Andrew Jeffery097495c2018-02-22 11:36:13 +103024 std::ofstream(path).write((const char *)data, len);
Andrew Jeffery812923d2018-02-22 11:59:52 +103025
26 return len;
27}
28
29} // test
30} // virtual_pnor
31} // openpower