# # patch "ChangeLog" # from [ae55065c097bcb4bf1f805408b49611d5533ddf5] # to [4c6d67b16c8bff1e2456242ab48d853d3d34dc34] # # patch "file_io.cc" # from [818512988302bec4b55e5221dd221a77e5532ec0] # to [9d4808690a65bb6c488bfbb32000bd386a6ff82e] # ======================================================================== --- ChangeLog ae55065c097bcb4bf1f805408b49611d5533ddf5 +++ ChangeLog 4c6d67b16c8bff1e2456242ab48d853d3d34dc34 @@ -1,5 +1,9 @@ 2005-08-25 Nathaniel Smith + * file_io.cc (move_file, move_dir): Implement. + +2005-08-25 Nathaniel Smith + * file_io.cc (assert_path_is_nonexistent, assert_path_is_file) (assert_path_is_directory, require_path_is_nonexistent) (require_path_is_file, require_path_is_directory) ======================================================================== --- file_io.cc 818512988302bec4b55e5221dd221a77e5532ec0 +++ file_io.cc 9d4808690a65bb6c488bfbb32000bd386a6ff82e @@ -173,61 +173,31 @@ } void -delete_dir_recursive(local_path const & p) +move_file(any_path const & old_path, + any_path const & new_path) { - N(directory_exists(p), - F("directory to delete '%s' does not exist") % p); - fs::remove_all(localized(p)); + require_path_is_file(old_path, + F("rename source file '%s' does not exist") % old_path, + F("rename source file '%s' is a directory " + "-- bug in monotone?") % old_path); + N(!path_exists(new_path), + F("rename target '%s' already exists") % new_path); + fs::rename(old_path, new_path); } void -move_file(file_path const & old_path, - file_path const & new_path) -{ - N(file_exists(old_path), - F("rename source file '%s' does not exist") % old_path); - N(! file_exists(new_path), - F("rename target file '%s' already exists") % new_path); - fs::rename(localized(old_path), - localized(new_path)); -} - -void -move_file(local_path const & old_path, - local_path const & new_path) -{ - N(file_exists(old_path), - F("rename source file '%s' does not exist") % old_path); - N(! file_exists(new_path), - F("rename target file '%s' already exists") % new_path); - fs::rename(localized(old_path), - localized(new_path)); -} - -void move_dir(file_path const & old_path, file_path const & new_path) { - N(directory_exists(old_path), - F("rename source dir '%s' does not exist") % old_path); - N(!directory_exists(new_path), - F("rename target dir '%s' already exists") % new_path); - fs::rename(localized(old_path), - localized(new_path)); + require_path_is_directory(old_path, + F("rename source dir '%s' does not exist") % old_path, + F("rename source dir '%s' is a file " + "-- bug in monotone?") % old_path); + N(!path_exists(new_path), + F("rename target '%s' already exists") % new_path); + fs::rename(old_path, new_path); } -void -move_dir(local_path const & old_path, - local_path const & new_path) -{ - N(directory_exists(old_path), - F("rename source dir '%s' does not exist") % old_path); - N(!directory_exists(new_path), - F("rename target dir '%s' already exists") % new_path); - fs::rename(localized(old_path), - localized(new_path)); -} - static void read_data_impl(fs::path const & p, data & dat)