Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sim/hostfs: pass flag O_BINARY to host #8997

Merged
merged 1 commit into from Apr 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions arch/sim/src/sim/win/sim_hostfs.c
Expand Up @@ -120,6 +120,22 @@ int host_open(const char *pathname, int flags, nuttx_mode_t mode)
mapflags |= O_TRUNC;
}

/* Since the initial default setting in MSVC is text mode ( O_TEXT ):
*
* https://learn.microsoft.com/en-us/cpp/c-runtime-library/ \
* text-and-binary-mode-file-i-o?view=msvc-170
*
* In order to unify the translation behavior with unix,
* 1. set O_BINARY for hostfs as default
* 2. enable default text mode if the application specifies flag O_TEXT
*
*/

if ((flags & NUTTX_O_TEXT) == 0)
{
mapflags |= O_BINARY;
}
anchao marked this conversation as resolved.
Show resolved Hide resolved

ret = _open(pathname, mapflags, mode);
if (ret == -1)
{
Expand Down