| Index: runtime/bin/directory_win.cc
|
| diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
|
| index 0fb1e1e245e3e29691162a3eb6bdad01831a9693..7fedd6c0bc9c29acd0c76219b1ced13c475c965f 100644
|
| --- a/runtime/bin/directory_win.cc
|
| +++ b/runtime/bin/directory_win.cc
|
| @@ -382,3 +382,19 @@ bool Directory::Delete(const char* dir_name, bool recursive) {
|
| return DeleteRecursively(dir_name);
|
| }
|
| }
|
| +
|
| +
|
| +bool Directory::Rename(const char* path, const char* new_path) {
|
| + ExistsResult exists = Exists(path);
|
| + if (exists != EXISTS) return false;
|
| + ExistsResult new_exists = Exists(new_path);
|
| + // MoveFile does not allow replacing exising directories. Therefore,
|
| + // if the new_path is currently a directory we need to delete it
|
| + // first.
|
| + if (new_exists == EXISTS) {
|
| + bool success = DeleteRecursively(new_path);
|
| + if (!success) return false;
|
| + }
|
| + DWORD flags = MOVEFILE_WRITE_THROUGH;
|
| + return (MoveFileEx(path, new_path, flags) != 0);
|
| +}
|
|
|