MCPcopy Create free account
hub / github.com/boostorg/filesystem / main

Function main

example/mbcopy.cpp:67–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65} // namespace
66
67int 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}

Callers

nothing calls this directly

Calls 6

statusMethod · 0.80
filenameMethod · 0.80
pathMethod · 0.80
copy_fileFunction · 0.70
is_directoryFunction · 0.50
is_regular_fileFunction · 0.50

Tested by

no test coverage detected