Skip to content

Commit

Permalink
Implement File.is_symlink.
Browse files Browse the repository at this point in the history
For symmetry with File.is_directory.

Fixes #11209.

PiperOrigin-RevId: 690652872
Change-Id: I4e93cb18e2469819cfa46f3c0685376093fc455e
  • Loading branch information
tjgq authored and bazel-io committed Oct 28, 2024
1 parent 57ce6a4 commit fc60bb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,11 @@ public boolean isDirectory() {
return false;
}

@Override
public boolean isSymlink() {
return false;
}

@Override
public String getRunfilesPathString() {
PathFragment relativePath = execPath.relativeTo(fileset.getExecPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,21 @@ public interface FileApi extends StarlarkValue {
@StarlarkMethod(
name = "is_directory",
structField = true,
doc = "Returns true if this is a directory.")
doc =
"Returns true if this is a directory. This reflects the type the file was declared as"
+ " (i.e. ctx.actions.declare_directory), not its type on the filesystem, which might"
+ " differ.")
boolean isDirectory();

@StarlarkMethod(
name = "is_symlink",
structField = true,
doc =
"Returns true if this is a directory. This reflects the type the file was declared as"
+ " (i.e. ctx.actions.declare_symlink), not its type on the filesystem, which might"
+ " differ.")
boolean isSymlink();

@StarlarkMethod(
name = "short_path",
structField = true,
Expand Down

0 comments on commit fc60bb6

Please sign in to comment.