Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2424)

Unified Diff: base/file_util_win.cc

Issue 319543004: Move and rename FdopenPlatformFile to file_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/platform_file.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(),
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/platform_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698