Skip to content
Extends `File` to provide `atomic_write()`.
Crystal Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
spec Updates specs for 0.30.1 Oct 17, 2019
src Fixes Formatting Jul 5, 2018
.gitignore Initial Commit May 17, 2018
LICENSE Initial Commit May 17, 2018
makefile Adds makefile May 30, 2018
shard.yml Version Bump, v0.1.4 Jul 5, 2018

Docs GitHub release Build Status

Extends File to provide atomic_write().

An atomic write creates a new file at a temporary path. It then writes the new file contents to that file. Lastly it renames it to the original path. This dramatically reduces the opportunity for file corruption.


Add this to your application's shard.yml:

    github: chris-huxtable/


require "atomic_write"

Atomic write:

File.atomic_write("some/path") { |fd| fd << "hello world" }

Atomic append:

File.atomic_write("some/path", append: true) { |fd| fd << "hello world" }

Atomic copy:

File.atomic_copy("some/src/path", "some/dst/path")


  1. Fork it ( )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request


You can’t perform that action at this time.