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

File#fsync, File#flock_exclusive, File#flock_shared, and File#flock_unlock belong in IO::FileDescriptor #9793

Closed
BrucePerens opened this issue Oct 2, 2020 · 1 comment
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. help wanted This issue is generally accepted and needs someone to pick it up

Comments

@BrucePerens
Copy link

Unix-style file operations, like File#fsync, File#flock_exclusive, File#flock_shared, and File#flock_unlock belong in IO::FileDescriptor. On Windows these are completely different APIs, which perhaps is why they are presently in File. However, this is a significant handicap on Unix-like systems and makes the user want to import the API from LibC, which would be ugly and even less portable.

An example of how to code these APIs portably to Windows is at https://github.com/WoLpH/portalocker

Why is the user using IO::FileDescriptor? They are doing operations on STDIN, STDOUT, or STDERR (which can be legitimate files), or on a file descriptor inherited from the parent process, or passed in from a foreign library.

@asterite
Copy link
Member

asterite commented Oct 3, 2020

I think this was just a short sight when we added these methods. PRs are welcome to move them to IO::FileDescriptor. It should be pretty straight-forward.

@asterite asterite added help wanted This issue is generally accepted and needs someone to pick it up good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. labels Oct 3, 2020
naqvis added a commit to naqvis/crystal that referenced this issue Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. help wanted This issue is generally accepted and needs someone to pick it up
Projects
None yet
Development

No branches or pull requests

2 participants