Feature #13696
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
renameat2(2) introduced in linux kernel 3.15 takes following flags. ``` RENAME_EXCHANGE: Atomically exchange oldpath and newpath. RENAME_NOREPLACE: Don't overwrite newpath of the rename. Return an error if newpath already exists. ``` This change makes `File.rename` File.rename take these flags as keyword arguments. Example: ```ruby ``` File.write("hoge", "hoge") File.write("fuga", "fuga") File.rename("hoge", "fuga", exchange: true) # atomically exchanged File.read("fuga") #=> "hoge" File.rename("hoge", "fuga", noreplace: true) #=> File exists @ syserr_fail2_in - fuga (Errno::EEXIST) ```