Index: base/file_util_win.cc |
diff --git a/base/file_util_win.cc b/base/file_util_win.cc |
index 90bc47faf8e9186bcf68aaef85d76ecbc68b4fa0..e3cd1f83ac29f35b1d5e6c9c65b20263046d58cc 100644 |
--- a/base/file_util_win.cc |
+++ b/base/file_util_win.cc |
@@ -5,6 +5,7 @@ |
#include "base/file_util.h" |
#include <windows.h> |
+#include <io.h> |
#include <psapi.h> |
#include <shellapi.h> |
#include <shlobj.h> |
@@ -578,6 +579,20 @@ FILE* OpenFile(const FilePath& filename, const char* mode) { |
return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO); |
} |
+FILE* FileToFILE(File file, const char* mode) { |
+ if (!file.IsValid()) |
+ return NULL; |
+ int fd = |
+ _open_osfhandle(reinterpret_cast<intptr_t>(file.GetPlatformFile()), 0); |
+ if (fd < 0) |
+ return NULL; |
+ file.TakePlatformFile(); |
+ FILE* stream = _fdopen(fd, mode); |
+ if (!stream) |
+ _close(fd); |
+ return stream; |
+} |
+ |
int ReadFile(const FilePath& filename, char* data, int max_size) { |
ThreadRestrictions::AssertIOAllowed(); |
base::win::ScopedHandle file(CreateFile(filename.value().c_str(), |