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.
Permalink
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
.travis.yml
LICENSE Initial Commit May 17, 2018
README.md
makefile Adds makefile May 30, 2018
shard.yml Version Bump, v0.1.4 Jul 5, 2018

README.md

atomic_write.cr

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.

Installation

Add this to your application's shard.yml:

dependencies:
  atomic_write:
    github: chris-huxtable/atomic_write.cr

Usage

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")

Contributing

  1. Fork it ( https://github.com/chris-huxtable/atomic_write.cr/fork )
  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

Contributors

You can’t perform that action at this time.