|
68 | 68 | #include "cuttlefish/common/libs/utils/contains.h" |
69 | 69 | #include "cuttlefish/common/libs/utils/in_sandbox.h" |
70 | 70 | #include "cuttlefish/common/libs/utils/users.h" |
| 71 | +#include "cuttlefish/posix/rename.h" |
71 | 72 | #include "cuttlefish/posix/strerror.h" |
72 | 73 | #include "cuttlefish/result/result.h" |
73 | 74 |
|
@@ -187,9 +188,7 @@ Result<void> MoveDirectoryContents(const std::string& source, |
187 | 188 | std::string src_filepath = source + "/" + filepath; |
188 | 189 | std::string dst_filepath = destination + "/" + filepath; |
189 | 190 | if (should_rename) { |
190 | | - CF_EXPECT(rename(src_filepath.c_str(), dst_filepath.c_str()) == 0, |
191 | | - "rename " << src_filepath << " to " << dst_filepath |
192 | | - << " failed: " << strerror(errno)); |
| 191 | + CF_EXPECT(Rename(src_filepath, dst_filepath)); |
193 | 192 | } else { |
194 | 193 | CF_EXPECT( |
195 | 194 | Copy(src_filepath, dst_filepath), |
@@ -490,9 +489,7 @@ Result<std::chrono::system_clock::time_point> FileModificationTime( |
490 | 489 | Result<std::string> RenameFile(const std::string& current_filepath, |
491 | 490 | const std::string& target_filepath) { |
492 | 491 | if (current_filepath != target_filepath) { |
493 | | - CF_EXPECT(rename(current_filepath.c_str(), target_filepath.c_str()) == 0, |
494 | | - "rename " << current_filepath << " to " << target_filepath |
495 | | - << " failed: " << strerror(errno)); |
| 492 | + CF_EXPECT(Rename(current_filepath, target_filepath)); |
496 | 493 | } |
497 | 494 | return target_filepath; |
498 | 495 | } |
|
0 commit comments