Index: base/files/file_util_win.cc |
diff --git a/base/files/file_util_win.cc b/base/files/file_util_win.cc |
index 4e67b5a348653f3af41d897f845ce4e0df4f2571..6eb2d71d3b73ad115edc9fedab4e3175d6187daf 100644 |
--- a/base/files/file_util_win.cc |
+++ b/base/files/file_util_win.cc |
@@ -70,6 +70,15 @@ bool DeleteFileRecursive(const FilePath& path, |
return true; |
} |
+// Appends |mode_char| to |mode| before the optional character set encoding; see |
+// https://msdn.microsoft.com/library/yeby3zcb.aspx for details. |
+void AppendModeCharacter(base::char16 mode_char, base::string16* mode) { |
+ // Add |mode_char| immediately before the comma or at the end of the string. |
Mark Mentovai
2017/02/11 00:52:29
Pretty much a dupe here too.
grt (UTC plus 2)
2017/02/13 07:53:28
Done.
|
+ size_t comma_pos = mode->find(L','); |
+ mode->insert(comma_pos == base::string16::npos ? mode->length() : comma_pos, |
+ 1, mode_char); |
+} |
+ |
} // namespace |
FilePath MakeAbsoluteFilePath(const FilePath& input) { |
@@ -586,8 +595,14 @@ bool GetFileInfo(const FilePath& file_path, File::Info* results) { |
} |
FILE* OpenFile(const FilePath& filename, const char* mode) { |
+ // 'N' is unconditionally added below, so be sure there is not one already |
+ // present before a comma in |mode|. |
+ DCHECK( |
+ strchr(mode, 'N') == nullptr || |
+ (strchr(mode, ',') != nullptr && strchr(mode, 'N') > strchr(mode, ','))); |
ThreadRestrictions::AssertIOAllowed(); |
string16 w_mode = ASCIIToUTF16(mode); |
+ AppendModeCharacter(L'N', &w_mode); |
return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO); |
} |