@epo I've added several tests including testing null masks and empty masks, which exposed a shortcoming in the cache reset in a very specific edge case. That's also been resolved in this pair of commits. I've squashed everything into two commits, and as requested I've flagged tests with `todo_wine` in the first, and then in the second I add the updated Wine behaviour, and remove the `todo_wine` flags.
I haven't yet rearranged the code in file.c, pending your response to my question above. Once we're happy with this I'll rebase the PR to bring it up-to-date