|
| 1 | +// Copyright 2018-2019 Delft University of Technology |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#include "fletchgen/static_vhdl.h" |
| 16 | + |
| 17 | +#include <cmrc/cmrc.hpp> |
| 18 | +#include <fstream> |
| 19 | +#include <algorithm> |
| 20 | +#include <sys/stat.h> |
| 21 | +#include <sys/types.h> |
| 22 | + |
| 23 | +CMRC_DECLARE(fletchgen); |
| 24 | + |
| 25 | +namespace fletchgen { |
| 26 | + |
| 27 | +void write_static_vhdl(const std::string &real_dir, const std::string &emb_dir) { |
| 28 | + mkdir(real_dir.c_str(), 0777); |
| 29 | + for (const auto &dirent : cmrc::fletchgen::get_filesystem().iterate_directory(emb_dir)) { |
| 30 | + if (dirent.is_file()) { |
| 31 | + std::ofstream real_file; |
| 32 | + real_file.open(real_dir + "/" + dirent.filename()); |
| 33 | + std::ostream_iterator<char> out_it{real_file}; |
| 34 | + auto emb_file = cmrc::fletchgen::get_filesystem().open(emb_dir + "/" + dirent.filename()); |
| 35 | + std::copy(emb_file.cbegin(), emb_file.cend(), out_it); |
| 36 | + real_file.close(); |
| 37 | + } else { |
| 38 | + write_static_vhdl(real_dir + "/" + dirent.filename(), emb_dir + "/" + dirent.filename()); |
| 39 | + } |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +} // namespace fletchgen |
0 commit comments