| Index: base/files/file_win.cc
|
| diff --git a/base/files/file_win.cc b/base/files/file_win.cc
|
| index 727b5ce1dbbe6e5e7be6e22cef8f1d450515b002..9f3033c845bb5a8e1469765c9b01c9b330167c7e 100644
|
| --- a/base/files/file_win.cc
|
| +++ b/base/files/file_win.cc
|
| @@ -309,6 +309,28 @@ File::Error File::Unlock() {
|
| return FILE_OK;
|
| }
|
|
|
| +File File::Duplicate() {
|
| + if (!IsValid())
|
| + return File();
|
| +
|
| + HANDLE other_handle = nullptr;
|
| +
|
| + if (!::DuplicateHandle(GetCurrentProcess(), // hSourceProcessHandle
|
| + GetPlatformFile(),
|
| + GetCurrentProcess(), // hTargetProcessHandle
|
| + &other_handle,
|
| + 0, // dwDesiredAccess ignored due to SAME_ACCESS
|
| + FALSE, // !bInheritHandle
|
| + DUPLICATE_SAME_ACCESS)) {
|
| + return File(OSErrorToFileError(GetLastError()));
|
| + }
|
| +
|
| + File other(other_handle);
|
| + if (async())
|
| + other.async_ = true;
|
| + return other.Pass();
|
| +}
|
| +
|
| // Static.
|
| File::Error File::OSErrorToFileError(DWORD last_error) {
|
| switch (last_error) {
|
|
|