we can't use boost::filesystem::copy_file() because the argument types differ, so provide a not-very-smart replacement.
| 30 | // we can't use boost::filesystem::copy_file() because the argument types |
| 31 | // differ, so provide a not-very-smart replacement. |
| 32 | void copy_file(const fs::wpath& from, const user::mbpath& to) |
| 33 | { |
| 34 | fs::ifstream from_file(from, std::ios_base::in | std::ios_base::binary); |
| 35 | if (!from_file) |
| 36 | { |
| 37 | std::cout << "input open failed\n"; |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | fs::ofstream to_file(to, std::ios_base::out | std::ios_base::binary); |
| 42 | if (!to_file) |
| 43 | { |
| 44 | std::cout << "output open failed\n"; |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | char c; |
| 49 | while (from_file.get(c)) |
| 50 | { |
| 51 | to_file.put(c); |
| 52 | if (to_file.fail()) |
| 53 | { |
| 54 | std::cout << "write error\n"; |
| 55 | return; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | if (!from_file.eof()) |
| 60 | { |
| 61 | std::cout << "read error\n"; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | } // namespace |
| 66 |