pathlib-abc icon indicating copy to clipboard operation
pathlib-abc copied to clipboard

Support for copy filters

Open barneygale opened this issue 7 months ago • 1 comments

It should be possible to implement copying filters similar to tarfile extraction filters: https://docs.python.org/3/library/tarfile.html#extraction-filters

barneygale avatar May 16 '25 20:05 barneygale

My current thinking:

  • absolute paths: handle via the .joinpath('_').with_name(name) idiom
  • symlink targets: the ReadablePath.copy() implementation should error out if a symlink target has a non-empty anchor or .. segment. The Path.copy() implementation would skip these checks if the target is local.
  • metadata: we add an info argument to __open_writer__(), mkdir() and symlink_to(). In pathlib.Path, we'd check whether isinstance(info, _LocalPathInfo). If it is, we fully trust the given info object and call some private methods. If it isn't, we copy only the permissions (subject to filtering) and access/modify times.

barneygale avatar Oct 10 '25 20:10 barneygale