mkfifo.cr
mkfifo
This small library monkey patches File
to add two new class methods: fifo
and fifo?
.
I made this because:
- I need it for my hobby project
- I found this dicussion about it, so others need it too
It's basically a copy of Ruby's File.mkfifo
, but I changed the permissions to match Crystal's default for new files.
Installation
-
Add the dependency to your
shard.yml
:dependencies: mkfifo: github: tijn/mkfifo
-
Run
shards install
Usage
require "mkfifo"
path = File.tempname
File.mkfifo(path)
File.fifo?(path) # ==> true
# read from the fifo, for example
File.each_line(path) do |line|
puts line
end
# or write to it:
File.open(path) do |fifo|
fifo.puts("foo and bar")
end
Contributing
- Fork it (https://github.com/tijn/mkfifo/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
- Tijn Schuurmans - creator and maintainer
Alternatives
I just found fifo.cr which takes a different approach, that is arguably somewhat cleaner since it avoids monkey patching.
Repository
mkfifo.cr
Owner
Statistic
- 1
- 0
- 0
- 0
- 0
- almost 3 years ago
- January 29, 2022
License
MIT License
Links
Synced at
Thu, 07 Nov 2024 09:22:45 GMT
Languages