From: KOSAKI Motohiro Date: 2013-01-30T13:28:39+09:00 Subject: [ruby-core:51749] Re: [ruby-trunk - Feature #7751] How to encapsulate File.delete and File.rename into one 'transaction'? > What a great function! I've confirm it is true. > > irb(main):001:0> File.write('src', '000') > => 3 > irb(main):002:0> File.write('dest', '1111') > => 4 > irb(main):003:0> File.rename('src', 'dest') > => 0 > irb(main):004:0> File.read('dest') > => "000" > > It is sorry that the doc of Ruby (Ruby19.chm) didn't describe it: > > rename(old_name, new_name) > Renames the given file to the new name. Raises a SystemCallError if the file cannot be renamed. > > File.rename("afile", "afile.bak") #=> 0 Because all File method behaviors depend on OS. It is not a part of ruby responsibility.