summaryrefslogtreecommitdiffstats
path: root/Lib/pathlib/_local.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/pathlib/_local.py')
-rw-r--r--Lib/pathlib/_local.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/pathlib/_local.py b/Lib/pathlib/_local.py
index bb8a252..250bc12 100644
--- a/Lib/pathlib/_local.py
+++ b/Lib/pathlib/_local.py
@@ -4,6 +4,7 @@ import operator
import os
import posixpath
import sys
+from errno import EXDEV
from glob import _StringGlobber
from itertools import chain
from _collections_abc import Sequence
@@ -876,6 +877,22 @@ class Path(PathBase, PurePath):
os.replace(self, target)
return self.with_segments(target)
+ def move(self, target):
+ """
+ Recursively move this file or directory tree to the given destination.
+ """
+ self._ensure_different_file(target)
+ try:
+ return self.replace(target)
+ except TypeError:
+ if not isinstance(target, PathBase):
+ raise
+ except OSError as err:
+ if err.errno != EXDEV:
+ raise
+ # Fall back to copy+delete.
+ return PathBase.move(self, target)
+
if hasattr(os, "symlink"):
def symlink_to(self, target, target_is_directory=False):
"""