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

Unified Diff: base/file_util_win.cc

Issue 6005: Cross-platform equivalent of fopen, _wfopen_s etc.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 3 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
Index: base/file_util_win.cc
===================================================================
--- base/file_util_win.cc (revision 2711)
+++ base/file_util_win.cc (working copy)
@@ -447,6 +447,24 @@
return true;
}
+FILE* OpenFile(const std::string& filename, const char* mode) {
+ std::wstring w_mode = ASCIIToWide(std::string(mode));
Mark Mentovai 2008/10/01 17:40:55 Not for fopen_s, you can just pass mode directly.
+ FILE* file;
+ if (fopen_s(&file, filename.c_str(), w_mode.c_str()) != 0) {
+ return NULL;
+ }
+ return file;
+}
+
+FILE* OpenFile(const std::wstring& filename, const char* mode) {
+ std::wstring w_mode = ASCIIToWide(std::string(mode));
+ FILE* file;
+ if (_wfopen_s(&file, filename.c_str(), w_mode.c_str()) != 0) {
+ return NULL;
+ }
+ return file;
+}
+
int ReadFile(const std::wstring& filename, char* data, int size) {
ScopedHandle file(CreateFile(filename.c_str(),
GENERIC_READ,
« no previous file with comments | « base/file_util_posix.cc ('k') | base/gfx/vector_canvas_unittest.cc » ('j') | base/trace_event.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698