Skip to content

std: fix compile error in std.fs.File.tryLock #23830

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HydroH
Copy link
Contributor

@HydroH HydroH commented May 8, 2025

Contributes to #21094 .

Handles unlock case in windows. Returns true if the file is not locked; this aligns with the behavior of posix systems.

@Rexicon226
Copy link
Contributor

See #21306 for a more lengthy discussion on fixing this compile error. You'll see that this fix isn't fully correct.

@HydroH
Copy link
Contributor Author

HydroH commented May 8, 2025

See #21306 for a more lengthy discussion on fixing this compile error. You'll see that this fix isn't fully correct.

Thanks for your review, it seems I'm missing the implementations in lock().

But in the case of behavior, I suppose a function should have the same behavior on different OSs? std.fs.File.tryLock will not panic on POSIX systems when trying to unlock files that are not locked, so I think behavior on Windows should be similar; also unlocking a file that is not locked is certainly not a codepath that will never be executed, and should not cause undefined behaviors.

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.

2 participants