| 65 | } // namespace |
| 66 | |
| 67 | int main(int argc, char* argv[]) |
| 68 | { |
| 69 | if (argc != 2) |
| 70 | { |
| 71 | std::cout << "Copy files in the current directory to a target directory\n" |
| 72 | << "Usage: mbcopy <target-dir>\n"; |
| 73 | return 1; |
| 74 | } |
| 75 | |
| 76 | // For encoding, use Boost UTF-8 codecvt |
| 77 | std::locale global_loc = std::locale(); |
| 78 | std::locale loc(global_loc, new fs::detail::utf8_codecvt_facet); |
| 79 | user::mbpath_traits::imbue(loc); |
| 80 | |
| 81 | std::string target_string(argv[1]); |
| 82 | user::mbpath target_dir(user::mbpath_traits::to_internal(target_string)); |
| 83 | |
| 84 | if (!fs::is_directory(target_dir)) |
| 85 | { |
| 86 | std::cout << "Error: " << argv[1] << " is not a directory\n"; |
| 87 | return 1; |
| 88 | } |
| 89 | |
| 90 | for (fs::wdirectory_iterator it(L"."); |
| 91 | it != fs::wdirectory_iterator(); ++it) |
| 92 | { |
| 93 | if (fs::is_regular_file(it->status())) |
| 94 | { |
| 95 | copy_file(*it, target_dir / it->path().filename()); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | return 0; |
| 100 | } |
nothing calls this directly
no test coverage detected