Commit 7973da6a by willmcgugan

Enhanced copyfile function

parent 3aa1997b
import shutil
def copyfile(src_fs, src_path, dst_fs, dst_path, chunk_size=1024*16):
def getsyspath(_fs, path):
try:
return _fs.getsyspath(path)
except NoSysPathError:
return ""
src_syspath = src_fs.getsyspath(src_path)
dst_syspath = dst_fs.getsyspath(dst_path)
# System copy if there are two sys paths
if src_syspath and dst_syspath:
shutil.copyfile(src_syspath, dst_syspath)
return
src = src_fs.open(src_path, 'rb')
dst = dst_fs.open(dst_path, 'wb')
# Chunk copy
while True:
chunk = src.read(chunk_size)
if not chunk:
break
dst.write(chunk)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment