Return true if the filename is reserved by the system.
(name)
| 316 | return any(_isreservedname(name) for name in reversed(path.split(sep))) |
| 317 | |
| 318 | def _isreservedname(name): |
| 319 | """Return true if the filename is reserved by the system.""" |
| 320 | # Trailing dots and spaces are reserved. |
| 321 | if name[-1:] in ('.', ' '): |
| 322 | return name not in ('.', '..') |
| 323 | # Wildcards, separators, colon, and pipe (*?"<>/\:|) are reserved. |
| 324 | # ASCII control characters (0-31) are reserved. |
| 325 | # Colon is reserved for file streams (e.g. "name:stream[:type]"). |
| 326 | if _reserved_chars.intersection(name): |
| 327 | return True |
| 328 | # DOS device names are reserved (e.g. "nul" or "nul .txt"). The rules |
| 329 | # are complex and vary across Windows versions. On the side of |
| 330 | # caution, return True for names that may not be reserved. |
| 331 | return name.partition('.')[0].rstrip(' ').upper() in _reserved_names |
| 332 | |
| 333 | |
| 334 | # Expand paths beginning with '~' or '~user'. |
no test coverage detected
searching dependent graphs…