Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

File creation behavior #33

Conversation

nclack
Copy link
Member

@nclack nclack commented Sep 21, 2023

closes #32

Adds a test, and modifies create_file() implementations across supported platforms so that they exhibit the following behavior:

  1. When creating a file for a path that already exists, creation should succeed, truncating the original file.
  2. When creating a file (for writing) that has already been opened for the process, creation should fail, and the original file should be unaffected.
  • windows - CreateFile api just does what we want. That one was already working.
  • osx - has a special flag we can pass to open that does what we want.
  • linux - use the flock api. According to man 2 flock this has been a syscall since kernel 2.0. Potentially racy, but that's probably ok.

@nclack nclack marked this pull request as ready for review September 21, 2023 04:42
Copy link
Contributor

@andy-sweet andy-sweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After checking the relevant posix docs, looks good to me.

@nclack nclack merged commit 40e71b2 into acquire-project:main Sep 21, 2023
3 checks passed
@nclack nclack deleted the 32-file-creation-behavior-causing-tests-to-fail branch September 21, 2023 18:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

file creation behavior causing tests to fail
3 participants