MCPcopy Index your code
hub / github.com/RustPython/RustPython / ensure_distinct_paths

Function ensure_distinct_paths

Lib/pathlib/_os.py:213–230  ·  view source on GitHub ↗

Raise OSError(EINVAL) if the other path is within this path.

(source, target)

Source from the content-addressed store, hash-verified

211
212
213def ensure_distinct_paths(source, target):
214 """
215 Raise OSError(EINVAL) if the other path is within this path.
216 """
217 # Note: there is no straightforward, foolproof algorithm to determine
218 # if one directory is within another (a particularly perverse example
219 # would be a single network share mounted in one location via NFS, and
220 # in another location via CIFS), so we simply checks whether the
221 # other path is lexically equal to, or within, this path.
222 if source == target:
223 err = OSError(EINVAL, "Source and target are the same path")
224 elif source in target.parents:
225 err = OSError(EINVAL, "Source path is a parent of target path")
226 else:
227 return
228 err.filename = str(source)
229 err.filename2 = str(target)
230 raise err
231
232
233def ensure_different_files(source, target):

Callers 2

copyMethod · 0.90
copyMethod · 0.90

Calls 1

strFunction · 0.85

Tested by

no test coverage detected