1662
1662
_terminal_size = _ioctl_terminal_size
1665
def supports_executable():
1666
return sys.platform != "win32"
1665
def supports_executable(path):
1666
"""Return if filesystem at path supports executable bit.
1668
:param path: Path for which to check the file system
1669
:return: boolean indicating whether executable bit can be stored/relied upon
1671
if sys.platform == 'win32':
1674
fs_type = get_fs_type(path)
1675
except errors.DependencyNotPresent as e:
1676
trace.mutter('Unable to get fs type for %r: %s', path, e)
1678
if fs_type in ('vfat', 'ntfs'):
1679
# filesystems known to not support executable bit
1684
def supports_symlinks(path):
1685
"""Return if the filesystem at path supports the creation of symbolic links.
1688
if not has_symlinks():
1691
fs_type = get_fs_type(path)
1692
except errors.DependencyNotPresent as e:
1693
trace.mutter('Unable to get fs type for %r: %s', path, e)
1695
if fs_type in ('vfat', 'ntfs'):
1696
# filesystems known to not support symlinks
1669
1701
def supports_posix_readonly():
2637
def get_fs_type(path):
2638
"""Return the filesystem type for the partition a path is in.
2640
:param path: Path to search filesystem type for
2641
:return: A FS type, as string. E.g. "ext2"
2643
# TODO(jelmer): It would be nice to avoid an extra dependency here, but the only
2644
# alternative is reading platform-specific files under /proc :(
2647
except ImportError as e:
2648
raise errors.DependencyNotPresent('psutil', e)
2650
if not PY3 and not isinstance(path, str):
2651
path = path.encode(_fs_enc)
2653
for part in sorted(psutil.disk_partitions(), key=lambda x: len(x.mountpoint), reverse=True):
2654
if is_inside(part.mountpoint, path):
2656
# Unable to parse the file? Since otherwise at least the entry for / should match..
2606
2661
perf_counter = time.perf_counter