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"))
|
||||
|
||||
|
||||
def rmtree(top):
|
||||
for path, dirs, files in os.walk(top, False):
|
||||
for f in files:
|
||||
os.unlink(path + "/" + f)
|
||||
os.rmdir(path)
|
||||
def rmtree(d):
|
||||
for name, type, *_ in os.ilistdir(d):
|
||||
path = d + "/" + name
|
||||
if type & 0x4000: # dir
|
||||
rmtree(path)
|
||||
else: # file
|
||||
os.unlink(path)
|
||||
os.rmdir(d)
|
||||
|
||||
|
||||
def copyfileobj(src, dest, length=512):
|
||||
|
|
Ładowanie…
Reference in New Issue