Skylark: File object can now retrieve dirname/basename.

--
MOS_MIGRATED_REVID=94478925
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
index c39c228..8220bd2 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
@@ -208,10 +208,26 @@
     return path;
   }
 
+  
   /**
-   * Returns the base file name of this artifact.
+   * Returns the directory name of this artifact, similar to dirname(1).
+   * 
+   * <p> The directory name is always a relative path to the execution directory.
+   */
+  @SkylarkCallable(name = "dirname", structField = true, 
+      doc = "The directory name of this artifact.")
+  public final String getDirname() {
+    PathFragment parent = getExecPath().getParentDirectory();
+    
+    return (parent == null) ? "/" : parent.getSafePathString();
+  }
+  
+  /**
+   * Returns the base file name of this artifact, similar to basename(1).
    */
   @Override
+  @SkylarkCallable(name = "basename", structField = true,
+      doc = "The base file name of this artifact.")
   public final String getFilename() {
     return getExecPath().getBaseName();
   }
@@ -230,8 +246,8 @@
    * for source artifacts if created without specifying the owner, or for special derived artifacts,
    * such as target completion middleman artifacts, build info artifacts, and the like.
    *
-   * When deserializing artifacts we end up with a dummy owner. In that case, it must be set using
-   * {@link #setArtifactOwner} before this method is called.
+   * <p>When deserializing artifacts we end up with a dummy owner. In that case, 
+   * it must be set using {@link #setArtifactOwner} before this method is called.
    */
   public final ArtifactOwner getArtifactOwner() {
     Preconditions.checkState(owner != DESERIALIZED_MARKER_OWNER, this);