diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/llnl/util/filesystem.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index 8581081e48..b39a17b52a 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -23,7 +23,7 @@ from llnl.util import tty from llnl.util.lang import dedupe, memoized from llnl.util.symlink import islink, symlink -from spack.util.executable import CommandNotFoundError, Executable, which +from spack.util.executable import Executable, which from spack.util.path import path_to_os_path, system_path_filter is_windows = _platform == "win32" @@ -117,13 +117,7 @@ def path_contains_subdirectory(path, root): @memoized def file_command(*args): """Creates entry point to `file` system command with provided arguments""" - try: - file_cmd = which("file", required=True) - except CommandNotFoundError as e: - if is_windows: - raise CommandNotFoundError("`file` utility is not available on Windows") - else: - raise e + file_cmd = which("file", required=True) for arg in args: file_cmd.add_default_arg(arg) return file_cmd @@ -134,7 +128,11 @@ def _get_mime_type(): """Generate method to call `file` system command to aquire mime type for a specified path """ - return file_command("-b", "-h", "--mime-type") + if is_windows: + # -h option (no-dereference) does not exist in Windows + return file_command("-b", "--mime-type") + else: + return file_command("-b", "-h", "--mime-type") @memoized |