[pypy-svn] pypy default: win32 implementations of os.unlink() and os.rename()
amauryfa
commits-noreply at bitbucket.org
Thu Jan 20 19:36:54 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch:
Changeset: r41072:561f58004f17
Date: 2011-01-20 18:34 +0100
http://bitbucket.org/pypy/pypy/changeset/561f58004f17/
Log: win32 implementations of os.unlink() and os.rename()
diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -1271,6 +1271,15 @@
if res < 0:
raise OSError(rposix.get_errno(), "os_unlink failed")
+ if sys.platform == 'win32':
+ from pypy.rpython.module.ll_win32file import make_win32_traits
+ win32traits = make_win32_traits(traits)
+
+ @func_renamer('unlink_llimpl_%s' % traits.str.__name__)
+ def unlink_llimpl(path):
+ if not win32traits.DeleteFile(path):
+ raise rwin32.lastWindowsError()
+
return extdef([traits.str], s_None, llimpl=unlink_llimpl,
export_name=traits.ll_os_name('unlink'))
@@ -1355,6 +1364,15 @@
if res < 0:
raise OSError(rposix.get_errno(), "os_rename failed")
+ if sys.platform == 'win32':
+ from pypy.rpython.module.ll_win32file import make_win32_traits
+ win32traits = make_win32_traits(traits)
+
+ @func_renamer('rename_llimpl_%s' % traits.str.__name__)
+ def rename_llimpl(oldpath, newpath):
+ if not win32traits.MoveFile(oldpath, newpath):
+ raise rwin32.lastWindowsError()
+
return extdef([traits.str, traits.str], s_None, llimpl=rename_llimpl,
export_name=traits.ll_os_name('rename'))
diff --git a/pypy/rpython/module/ll_win32file.py b/pypy/rpython/module/ll_win32file.py
--- a/pypy/rpython/module/ll_win32file.py
+++ b/pypy/rpython/module/ll_win32file.py
@@ -162,6 +162,16 @@
[traits.CCHARP, traits.CCHARP],
rwin32.BOOL)
+ DeleteFile = external(
+ 'DeleteFile' + suffix,
+ [traits.CCHARP],
+ rwin32.BOOL)
+
+ MoveFile = external(
+ 'MoveFile' + suffix,
+ [traits.CCHARP, traits.CCHARP],
+ rwin32.BOOL)
+
return Win32Traits
#_______________________________________________________________
More information about the Pypy-commit
mailing list