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

Function main

example/mbcopy.cpp:52–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52int main( int argc, char * argv[] )
53{
54 if ( argc != 2 )
55 {
56 std::cout << "Copy files in the current directory to a target directory\n"
57 << "Usage: mbcopy <target-dir>\n";
58 return 1;
59 }
60
61 // For encoding, use Boost UTF-8 codecvt
62 std::locale global_loc = std::locale();
63 std::locale loc( global_loc, new fs::detail::utf8_codecvt_facet );
64 user::mbpath_traits::imbue( loc );
65
66 std::string target_string( argv[1] );
67 user::mbpath target_dir( user::mbpath_traits::to_internal( target_string ) );
68
69 if ( !fs::is_directory( target_dir ) )
70 {
71 std::cout << "Error: " << argv[1] << " is not a directory\n";
72 return 1;
73 }
74
75 for ( fs::wdirectory_iterator it( L"." );
76 it != fs::wdirectory_iterator(); ++it )
77 {
78 if ( fs::is_regular_file(it->status()) )
79 {
80 copy_file( *it, target_dir / it->path().filename() );
81 }
82 }
83
84 return 0;
85}
86
87
88

Callers

nothing calls this directly

Calls 5

is_directoryFunction · 0.85
is_regular_fileFunction · 0.85
statusMethod · 0.80
filenameMethod · 0.80
copy_fileFunction · 0.70

Tested by

no test coverage detected