Skip to content

Conversation

@MagnetoMallard
Copy link

@MagnetoMallard MagnetoMallard commented Mar 21, 2025

Description

in windows, using the fopen function locks the file for other programs. Therefore, the hot-reloading features would not work on windows. This behaviour is described in the documentation for fopen_s, but it can be assumed to apply to fopen as well. This is an attempt to fix that given the documentations recommendations to use _fsopen with explictly set shared file access permissions instead.

This was tried at first, but it appeared to not be sufficient, as _fsopen does not have any permission set that allows files to be removed - you have to use lower level WinAPI functions to open files in a way that allows other applications to delete them.

Motivation and Context

As discussed on Discord!

How Has This Been Tested?

I am testing this now with the PR build, since I was struggling to set up the Windows build on my machine. will make further commits if it doesn't work!

@MagnetoMallard MagnetoMallard changed the title fix: uses _fsopen to open files on windows with shared permissions fix: uses alternative method to open files on windows with shared permissions Mar 22, 2025
@MagnetoMallard
Copy link
Author

I am closing this for now as it turns out that the inability for the rom file to be over-written was being caused by dangling file handles being left open by other parts of the code!

So we don't need this. But if we ever do need to explicitly specify the handle on windows (in case Windows ever decides to get more strict about this, who knows), it can always be reopened!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant