kopia lustrzana https://github.com/micropython/micropython-lib
shutil: Implement copyfileobj().
rodzic
c89a9fd7b1
commit
a03e185f0d
|
@ -7,3 +7,15 @@ def rmtree(top):
|
||||||
for f in files:
|
for f in files:
|
||||||
os.unlink(path + "/" + f)
|
os.unlink(path + "/" + f)
|
||||||
os.rmdir(path)
|
os.rmdir(path)
|
||||||
|
|
||||||
|
def copyfileobj(src, dest, length=512):
|
||||||
|
buf = bytearray(length)
|
||||||
|
while True:
|
||||||
|
sz = src.readinto(buf)
|
||||||
|
if not sz:
|
||||||
|
break
|
||||||
|
if sz == length:
|
||||||
|
dest.write(buf)
|
||||||
|
else:
|
||||||
|
b = memoryview(buf)[:sz]
|
||||||
|
dest.write(b)
|
||||||
|
|
Ładowanie…
Reference in New Issue