Return whether path exists - checking path components in case sensitive fashion, up to prefix.
(self, path: str, prefix: str)
| 224 | return res |
| 225 | |
| 226 | def exists_case(self, path: str, prefix: str) -> bool: |
| 227 | """Return whether path exists - checking path components in case sensitive |
| 228 | fashion, up to prefix. |
| 229 | """ |
| 230 | if path in self.exists_case_cache: |
| 231 | return self.exists_case_cache[path] |
| 232 | head, tail = os.path.split(path) |
| 233 | if not head.startswith(prefix) or not tail: |
| 234 | # Only perform the check for paths under prefix. |
| 235 | self.exists_case_cache[path] = True |
| 236 | return True |
| 237 | try: |
| 238 | names = self.listdir(head) |
| 239 | # This allows one to check file name case sensitively in |
| 240 | # case-insensitive filesystems. |
| 241 | res = tail in names |
| 242 | except OSError: |
| 243 | res = False |
| 244 | if res: |
| 245 | # Also recursively check other path components. |
| 246 | res = self.exists_case(head, prefix) |
| 247 | self.exists_case_cache[path] = res |
| 248 | return res |
| 249 | |
| 250 | def isdir(self, path: str) -> bool: |
| 251 | st = self.stat_or_none(path) |
no test coverage detected