[issue8828] Atomic function to rename a file

Antoine Pitrou report at bugs.python.org
Mon Oct 24 18:40:28 CEST 2011


Antoine Pitrou <pitrou at free.fr> added the comment:

I see that Sun/Oracle Java trusts MoveFileEx to do atomic renames:

  290           // atomic case
  291           if (atomicMove) {
  292               try {
  293                   MoveFileEx(sourcePath, targetPath, MOVEFILE_REPLACE_EXISTING);
  294               } catch (WindowsException x) {
  295                   if (x.lastError() == ERROR_NOT_SAME_DEVICE) {
  296                       throw new AtomicMoveNotSupportedException(
  297                           source.getPathForExceptionMessage(),
  298                           target.getPathForExceptionMessage(),
  299                           x.errorString());
  300                   }
  301                   x.rethrowAsIOException(source, target);
  302               }
  303               return;
  304           }

(from http://www.docjar.com/html/api/sun/nio/fs/WindowsFileCopy.java.html )

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8828>
_______________________________________


More information about the Python-bugs-list mailing list