From 1d1078fd8b49bd501e11676d0bdb73d3bb515efc Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 8 Dec 2014 17:45:17 -0500 Subject: Kernel/File: Fixed file read/write hwtests The 3DS allows the user to read from files opened with the Write access modifier, even if he did not specify the Read access modifier. Open the files in binary mode so that we can prevent CR/LF problems in Windows, where a line-end is replaced by these two bytes instead of just 0xA, this was causing problems with the GetSize test --- src/core/file_sys/file_sdmc.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/file_sys/file_sdmc.cpp b/src/core/file_sys/file_sdmc.cpp index a4b90670a..b01d96e3d 100644 --- a/src/core/file_sys/file_sdmc.cpp +++ b/src/core/file_sys/file_sdmc.cpp @@ -38,12 +38,15 @@ bool File_SDMC::Open() { } std::string mode_string; - if (mode.read_flag && mode.write_flag) + if (mode.create_flag) mode_string = "w+"; + else if (mode.write_flag) + mode_string = "r+"; // Files opened with Write access can be read from else if (mode.read_flag) mode_string = "r"; - else if (mode.write_flag) - mode_string = "w"; + + // Open the file in binary mode, to avoid problems with CR/LF on Windows systems + mode_string += "b"; file = new FileUtil::IOFile(path, mode_string.c_str()); return true; -- cgit v1.2.3