Skip to content

Can't append to file on windows without blocking #15680

Closed
@ysbaddaden

Description

@ysbaddaden

While we can read and write to files asynchronously on Windows (by passing blocking: false so FILE_FLAG_OVERLAPPED is set), trying to append to an existing file will actually overwrite the file.

The following example is an extract from spec/std/file_spec.cr that reproduces the problem:

path = "append.txt"

File.write(path, "hello", blocking: false)
p File.read(path, blocking: false)
# => "hello"

File.write(path, " world", mode: "a", blocking: false)
p File.read(path, blocking: false)
# => " world"

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugA bug in the code. Does not apply to documentation, specs, etc.platform:windowsWindows support based on the MSVC toolchain / Win32 APItopic:stdlib:files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions