summaryrefslogtreecommitdiffstats
path: root/base/file_util_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/file_util_win.cc')
-rw-r--r--base/file_util_win.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 6a89b3f..fc53dc9 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -447,6 +447,23 @@ bool GetFileInfo(const std::wstring& file_path, FileInfo* results) {
return true;
}
+FILE* OpenFile(const std::string& filename, const char* mode) {
+ FILE* file;
+ if (fopen_s(&file, filename.c_str(), mode) != 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,