[#81492] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — normalperson@...

Issue #13618 has been reported by normalperson (Eric Wong).

12 messages 2017/06/01

[ruby-core:81823] [Ruby trunk Feature#13696] Add exchange and noreplace options to File.rename

From: glass.saga@...
Date: 2017-06-29 03:07:39 UTC
List: ruby-core #81823
Issue #13696 has been reported by Glass_saga (Masaki Matsushita).

----------------------------------------
Feature #13696: Add exchange and noreplace options to File.rename
https://bugs.ruby-lang.org/issues/13696

* Author: Glass_saga (Masaki Matsushita)
* Status: Open
* Priority: Normal
* Assignee: Glass_saga (Masaki Matsushita)
* Target version: 2.5
----------------------------------------
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 take these flags as keyword arguments.

Example:

```
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)
```

---Files--------------------------------
patch.diff (4.19 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next