def dirents(buf):
 d = []
 while buf:
  try:
   ent = linux_dirent(buf)
  except ValueError:
   break
  d.append(ent.d_name)
  buf = buf[len(ent):]
 return sorted(d)

def dirents ( buf ) : d = [ ] while buf : try : ent = linux_dirent ( buf ) except ValueError : break d . append ( ent . d_name ) buf = buf [ len ( ent ) : ] return sorted ( d )
unpack_dents -> list extracts data from a buffer emitted by getdents() arguments: buf: byte array returns: a list of filenames .