| # Return a sorted list of the files in a directory, using a cache |
| # to avoid reading the directory more often than necessary. |
| # Also contains a subroutine to append slashes to directories. |
| def listdir(path): # List directory contents, using cache |
| cached_mtime, list = cache[path] |
| cached_mtime, list = -1, [] |
| if mtime <> cached_mtime: |
| cache[path] = mtime, list |
| opendir = listdir # XXX backward compatibility |
| def annotate(head, list): # Add '/' suffixes to directories |
| for i in range(len(list)): |
| if os.path.isdir(os.path.join(head, list[i])): |