Skip to content

Commit 8884dbb

Browse files
committed
os: Refactor ilistdir() to be compatible with builtin uos.ilistdir().
1 parent e9648da commit 8884dbb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

os/os/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def makedirs(name, mode=0o777, exist_ok=False):
122122
if e.args[0] != errno.EEXIST:
123123
raise
124124

125-
def ilistdir_ex(path="."):
125+
def ilistdir(path="."):
126126
dir = opendir_(path)
127127
if not dir:
128128
raise_error()
@@ -134,13 +134,14 @@ def ilistdir_ex(path="."):
134134
break
135135
dirent = ffi.as_bytearray(dirent, struct.calcsize(dirent_fmt))
136136
dirent = struct.unpack(dirent_fmt, dirent)
137+
dirent = (dirent[-1].split(b'\0', 1)[0], dirent[-2], dirent[0])
137138
yield dirent
138139

139140
def listdir(path="."):
140141
is_str = type(path) is not bytes
141142
res = []
142-
for dirent in ilistdir_ex(path):
143-
fname = dirent[4].split(b'\0', 1)[0]
143+
for dirent in ilistdir(path):
144+
fname = dirent[0]
144145
if fname != b"." and fname != b"..":
145146
if is_str:
146147
fname = fsdecode(fname)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy