atomic_write
Version, currently 0.2.07 versions
github.com/chris-huxtable/atomic_write.cr
Extends `File` to provide `atomic_write()`, `atomic_replace()`
13 stars
1 dependent
License: ISC
Installation
# Add this to your shard.yml
dependencies:
atomic_write:
github: chris-huxtable/atomic_write.cr
version: ~> 0.2.0Then run:
shards installshard.yml
- Crystal
>= 0.35- License
- ISC
- Author
- Chris Huxtable
Dependencies
This version declares no dependencies.
README
atomic_write.cr
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")
Atomic replace:
File.atomic_replace("some/src/path") { |src_fd, dst_fd| dst_fd << "hello" << src_fd.gets_to_end }
Contributing
- Fork it ( https://github.com/chris-huxtable/atomic_write.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- Chris Huxtable - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.0- Tagged
- Mar 23, 2022
- Commit
aa11935a21c0- Crystal
>= 0.35- Indexed
- yes
Dependents
Repository
github.com/chris-huxtable/atomic_write.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 13, 2026
- Synced
- Aug 13, 2026
- Versions
- 7