sonic-pi

https://github.com/sonic-pi-net/sonic-pi

C++

Code. Music. Live.

File.atomic_write

Write to a file atomically. Useful for situations where you don't
want other processes or threads to see half-written files.

  File.atomic_write('important.file') do |file|
    file.write('hello')
  end

If your temp directory is not on the same filesystem as the file you're
trying to write, you can provide a different temporary directory.

  File.atomic_write('/data/something.important', '/data/tmp') do |file|
    file.write('hello')
  end

Source | Google | Stack overflow

Edit

git clone [email protected]:sonic-pi-net/sonic-pi.git

cd sonic-pi

open app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/file/atomic.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-File-atomic_write-for-pr


# Commit to git

git add app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/file/atomic.rbgit commit -m "better docs for File.atomic_write"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-File-atomic_write-for-pr

hub pull-request


# Celebrate!