kopia lustrzana https://github.com/micropython/micropython-lib
shutil: Fix shutil.rmtree to use os.ilistdir instead of os.walk.
rodzic
ee286ed28c
commit
4ae896afdc
|
@ -5,11 +5,14 @@ from collections import namedtuple
|
||||||
_ntuple_diskusage = namedtuple("usage", ("total", "used", "free"))
|
_ntuple_diskusage = namedtuple("usage", ("total", "used", "free"))
|
||||||
|
|
||||||
|
|
||||||
def rmtree(top):
|
def rmtree(d):
|
||||||
for path, dirs, files in os.walk(top, False):
|
for name, type, *_ in os.ilistdir(d):
|
||||||
for f in files:
|
path = d + "/" + name
|
||||||
os.unlink(path + "/" + f)
|
if type & 0x4000: # dir
|
||||||
os.rmdir(path)
|
rmtree(path)
|
||||||
|
else: # file
|
||||||
|
os.unlink(path)
|
||||||
|
os.rmdir(d)
|
||||||
|
|
||||||
|
|
||||||
def copyfileobj(src, dest, length=512):
|
def copyfileobj(src, dest, length=512):
|
||||||
|
|
Ładowanie…
Reference in New Issue