[pypy-commit] pypy follow_symlinks: hg merge rposix-for-3

rlamy pypy.commits at gmail.com
Sat Mar 26 00:15:37 EDT 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: follow_symlinks
Changeset: r83385:b61310248d8f
Date: 2016-03-26 04:11 +0000
http://bitbucket.org/pypy/pypy/changeset/b61310248d8f/

Log:	hg merge rposix-for-3

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -1903,6 +1903,17 @@
         lltype.free(buf, flavor='raw')
         return result
 
+if HAVE_RENAMEAT:
+    c_renameat = external(
+        'renameat',
+        [rffi.INT, rffi.CCHARP, rffi.INT, rffi.CCHARP], rffi.INT,
+        save_err=rffi.RFFI_SAVE_ERRNO)
+
+    def renameat(src, dst, src_dir_fd=AT_FDCWD, dst_dir_fd=AT_FDCWD):
+        error = c_renameat(src_dir_fd, src, dst_dir_fd, dst)
+        handle_posix_error('renameat', error)
+
+
 if HAVE_SYMLINKAT:
     c_symlinkat = external('symlinkat',
         [rffi.CCHARP, rffi.INT, rffi.CCHARP], rffi.INT,
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -545,3 +545,14 @@
         assert os.readlink(str(tmpdir.join('link'))) == 'file'
     finally:
         os.close(dirfd)
+
+
+def test_renameat(tmpdir):
+    tmpdir.join('file').write('text')
+    dirfd = os.open(str(tmpdir), os.O_RDONLY)
+    try:
+        rposix.renameat('file', 'file2', src_dir_fd=dirfd, dst_dir_fd=dirfd)
+    finally:
+        os.close(dirfd)
+    assert tmpdir.join('file').check(exists=False)
+    assert tmpdir.join('file2').check(exists=True)


More information about the pypy-commit mailing list