# # patch "ChangeLog" # from [49c41f292efe8d05f3e53cbe11ec7283e877842d] # to [f7c419896a3e34d2a451ced5f19ad373b448c5aa] # # patch "file_io.cc" # from [a887c87104212bab175b54ec1ceb1fa5153024e5] # to [060b7730036e800c57b77676e92683e79de0094f] # # patch "file_io.hh" # from [87da82801eb51bc7297c917637e2895bd60ba8bc] # to [b8d941b217728649a865b8123309a441904b0884] # ======================================================================== --- ChangeLog 49c41f292efe8d05f3e53cbe11ec7283e877842d +++ ChangeLog f7c419896a3e34d2a451ced5f19ad373b448c5aa @@ -1,5 +1,9 @@ 2005-08-30 Nathaniel Smith + * file_io.cc (walk_tree_absolute): Implement. + +2005-08-30 Nathaniel Smith + * commands.cc (cvs_import, git_import): Fixup after merge. * git.hh (import_git_repo): Port to paths.cc. * git.cc: Port to paths.cc generally. ======================================================================== --- file_io.cc a887c87104212bab175b54ec1ceb1fa5153024e5 +++ file_io.cc 060b7730036e800c57b77676e92683e79de0094f @@ -455,13 +455,70 @@ walker.visit_file(path); break; case path::directory: - walk_tree_recursive(system_path(path).as_external(), - path.as_external(), + walk_tree_recursive(mkdir(system_path(path)), + mkdir(path), walker); break; } } +absolute_tree_walker::~absolute_tree_walker() {} + +static void +walk_tree_recursive(fs::path const & absolute, + absolute_tree_walker & walker) +{ + fs::directory_iterator ei; + for(fs::directory_iterator di(absolute); + di != ei; ++di) + { + fs::path entry = *di; + + if (!fs::exists(entry) + || di->string() == "." + || di->string() == "..") + ; // ignore + else if (fs::is_directory(entry)) + walk_tree_recursive(entry, walker); + else + { + system_path p; + try + { + // FIXME: BUG: this screws up charsets + p = system_path(entry.normalize().string()); + } + catch (std::runtime_error const & c) + { + W(F("caught runtime error %s constructing file path for %s\n") + % c.what() % entry.string()); + continue; + } + walker.visit_file(p); + } + } +} + +void +walk_tree_absolute(system_path const & path, + absolute_tree_walker & walker, + bool require_existing_path) +{ + switch (get_path_status(path)) + { + case path::nonexistent: + N(require_existing_path, F("no such file or directory") % path); + walker.visit_file(path); + break; + case path::file: + walker.visit_file(path); + break; + case path::directory: + walk_tree_recursive(mkdir(path), walker); + break; + } +} + #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" ======================================================================== --- file_io.hh 87da82801eb51bc7297c917637e2895bd60ba8bc +++ file_io.hh b8d941b217728649a865b8123309a441904b0884 @@ -105,7 +105,8 @@ void walk_tree_absolute(system_path const & path, - absolute_tree_walker & walker); + absolute_tree_walker & walker, + bool require_existing_path = true);