Return a closure that attempts to read a directory listing.
()
| 83 | |
| 84 | |
| 85 | def _try_read(): |
| 86 | """Return a closure that attempts to read a directory listing.""" |
| 87 | |
| 88 | def fn(path): |
| 89 | import os |
| 90 | |
| 91 | try: |
| 92 | entries = os.listdir(path) |
| 93 | return f"OK:{len(entries)}" |
| 94 | except PermissionError: |
| 95 | return "EPERM" |
| 96 | except OSError as e: |
| 97 | return f"ERROR:{e.errno}" |
| 98 | |
| 99 | return fn |
| 100 | |
| 101 | |
| 102 | def _check_user_owns_path(): |
no outgoing calls
no test coverage detected