Index: base/files/file_posix.cc |
diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc |
index 245ea6a8ebddf2f5b19f9aaa41f5ae8c1315ef17..f2d582dc16c570447e308fddf354ce105de296b2 100644 |
--- a/base/files/file_posix.cc |
+++ b/base/files/file_posix.cc |
@@ -463,6 +463,20 @@ File::Error File::Unlock() { |
return CallFctnlFlock(file_.get(), false); |
} |
+File File::Duplicate() { |
+ if (!IsValid()) |
+ return File(); |
+ |
+ PlatformFile other_fd = dup(GetPlatformFile()); |
+ if (other_fd == -1) |
+ return File(OSErrorToFileError(errno)); |
+ |
+ File other(other_fd); |
+ if (async()) |
+ other.async_ = true; |
+ return other.Pass(); |
+} |
+ |
// Static. |
File::Error File::OSErrorToFileError(int saved_errno) { |
switch (saved_errno) { |