Shortcuts

mmengine.fileio.copyfile

mmengine.fileio.copyfile(src, dst, backend_args=None)[source]

Copy a file src to dst and return the destination file.

src and dst should have the same prefix. If dst specifies a directory, the file will be copied into dst using the base filename from src. If dst specifies a file that already exists, it will be replaced.

Parameters
  • src (str or Path) – A file to be copied.

  • dst (str or Path) – Copy file to dst.

  • backend_args (dict, optional) – Arguments to instantiate the corresponding backend. Defaults to None.

Returns

The destination file.

Return type

str

Raises

SameFileError – If src and dst are the same file, a SameFileError will be raised.

Examples

>>> # dst is a file
>>> src = '/path/of/file'
>>> dst = '/path1/of/file1'
>>> # src will be copied to '/path1/of/file1'
>>> copyfile(src, dst)
'/path1/of/file1'
>>> # dst is a directory
>>> dst = '/path1/of/dir'
>>> # src will be copied to '/path1/of/dir/file'
>>> copyfile(src, dst)
'/path1/of/dir/file'
Read the Docs v: v0.8.3
Versions
latest
stable
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.