kopia lustrzana https://github.com/micropython/micropython-lib
upysh: ls: Print file size/directory type.
rodzic
459c8969bc
commit
893d03aabd
|
@ -4,15 +4,18 @@ import os
|
||||||
class LS:
|
class LS:
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
l = os.listdir()
|
self.__call__()
|
||||||
l.sort()
|
return ""
|
||||||
return "\n".join(l)
|
|
||||||
|
|
||||||
def __call__(self, path="."):
|
def __call__(self, path="."):
|
||||||
l = os.listdir(path)
|
l = os.listdir(path)
|
||||||
l.sort()
|
l.sort()
|
||||||
for f in l:
|
for f in l:
|
||||||
print(f)
|
st = os.stat("%s/%s" % (path, f))
|
||||||
|
if st[0] & 0x4000: # stat.S_IFDIR
|
||||||
|
print(" <dir> %s" % f)
|
||||||
|
else:
|
||||||
|
print("% 8d %s" % (st[6], f))
|
||||||
|
|
||||||
class PWD:
|
class PWD:
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue