Commit fcaa2b10 authored by Silvan Mosberger's avatar Silvan Mosberger
Browse files

lib.filesystem.pathType: Use new builtins.readFileType if available

parent 84a3d633
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -32,7 +32,10 @@ in
      pathType /some/file.nix
      => "regular"
  */
  pathType = path:
  pathType =
    builtins.readFileType or
    # Nix <2.14 compatibility shim
    (path:
      if ! pathExists path
      # Fail irrecoverably to mimic the historic behavior of this function and
      # the new builtins.readFileType
@@ -42,7 +45,8 @@ in
      # "directory", since we know the filesystem root can't be anything else.
      else if dirOf path == path
      then "directory"
    else (readDir (dirOf path)).${baseNameOf path};
      else (readDir (dirOf path)).${baseNameOf path}
    );

  /*
    Whether a path exists and is a directory.