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

os.touchfile leaves a spurious whitespace on Windows #1399

Closed
nsprljan opened this issue Feb 11, 2020 · 0 comments · Fixed by #1485
Closed

os.touchfile leaves a spurious whitespace on Windows #1399

nsprljan opened this issue Feb 11, 2020 · 0 comments · Fixed by #1485
Labels

Comments

@nsprljan
Copy link
Contributor

os.touchfile is implemented (in public/core/src/host/os_touchfile.c) by inserting one empty space at the end of the file, and then truncating it to the original size. A comment there suggests this is done in order to have a simple multiplatform implementation. However, on Windows it does not work fully as intended - it's touched alright, but the file does not get truncated, resulting in a file containing a bogus change.

Perhaps this worked at some point and in the meantime something changed in the CRT, and I am not sure what is wrong exactly, but my bet would be on OS having multiple handles to the files (because of difference in CRT functions used) and not flushing the changes when fclose is called. Anyway, here's a patch that fixed it for me, perhaps will be of some use:
https://gist.github.com/nsprljan/6c2902794b897a51a2534028cd4bbc6e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant