# # patch "ChangeLog" # from [2d8c5048899756f8d99e450c470e5704458597a3] # to [d4658ad1aad6e4851fb3110ce6e5c4f445a4bf64] # # patch "file_io.cc" # from [041a81978fe4ec6eb0fae72663d56474a5c34f92] # to [49f4c5d4aee61b47d3f7fcf7fec01623f9ff4046] # ======================================================================== --- ChangeLog 2d8c5048899756f8d99e450c470e5704458597a3 +++ ChangeLog d4658ad1aad6e4851fb3110ce6e5c4f445a4bf64 @@ -1,5 +1,9 @@ 2005-08-25 Nathaniel Smith + * file_io.cc (walk_tree_recursive, walk_tree): Implement. + +2005-08-25 Nathaniel Smith + * paths.cc (const_system_path): Do tilde expansion. 2005-08-25 Nathaniel Smith ======================================================================== --- file_io.cc 041a81978fe4ec6eb0fae72663d56474a5c34f92 +++ file_io.cc 49f4c5d4aee61b47d3f7fcf7fec01623f9ff4046 @@ -377,11 +377,12 @@ file_path p; try { - p = file_path(rel_entry.string()); + // FIXME: BUG: this screws up charsets + p = file_path_internal(rel_entry.normalize().string()); } catch (std::runtime_error const & c) { - L(F("caught runtime error %s constructing file path for %s\n") + W(F("caught runtime error %s constructing file path for %s\n") % c.what() % rel_entry.string()); continue; } @@ -396,40 +397,26 @@ tree_walker & walker, bool require_existing_path) { - if (fs::exists(localized(path))) + if (path.empty()) + walk_tree_recursive(fs::current_path(), fs::path(), walker); + + switch (get_path_status(path)) { - if (! fs::is_directory(localized(path))) - walker.visit_file(path); - else - { - // the current path does not need localization - fs::path root(fs::current_path()); - fs::path rel(localized(path)); - walk_tree_recursive(root / rel, rel, walker); - } + 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(system_path(path).as_external(), + path.as_external(), + walker); + break; } - else - { - if (require_existing_path) - { - N(false, - F("no such file or directory: %s") % path()); - } - else - { - walker.visit_file(path); - } - } } -// from cwd (nb: we can't describe cwd as a file_path) -void -walk_tree(tree_walker & walker) -{ - walk_tree_recursive(fs::current_path(), fs::path(), walker); -} - - #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh"