Commit 6e4c57b
committed
Hotfix #5629 read_as_string should open as binary
Root cause: read_as_string(const openstudio::path& t_path) in src/utilities/core/FilesystemHelpers.cpp opened the file with openstudio::filesystem::ifstream f(t_path); — no std::ios_base::binary flag. On Windows this defaults to text mode, which translates \r\n → \n while reading.
The underlying read() helper computes file_len from tellg()/seekg() (the raw on-disk byte count) and then does a single t_file.read(&buf.front(), file_len). In text mode, the CRLF translation means fewer characters actually get read than the buffer was sized for, so the string gets truncated/corrupted with trailing garbage — silently, no error. This only manifests on Windows since POSIX has no text/binary distinction, which matches the "Windows and only Windows" symptom, and explains why parsing barreled all the way to line 8769 before choking on garbage.
The sibling function read(const path&) already correctly used std::ios_base::binary — the string-returning overload just missed it.
Fix: src/utilities/core/FilesystemHelpers.cpp:38 — added std::ios_base::binary to match.
Verified by rebuilding openstudio_utilities_tests and running:
- --gtest_filter=*EpwFile_UTF8BOM* → now passes
- --gtest_filter=Filetypes.* → all 63 tests pass, no regressions1 parent 79253ab commit 6e4c57b
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
0 commit comments