Browse Source

Delegate validation to DestDir. This has a nice effect on MkDir as at least

one 'unknown reason' (Path containing an existing non-directory element) will
be known by using DestDir.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270386 13f79535-47bb-0310-9956-ffa450edef68
master
Magesh Umasankar 23 years ago
parent
commit
18897c517a
1 changed files with 16 additions and 7 deletions
  1. +16
    -7
      src/main/org/apache/tools/ant/taskdefs/Mkdir.java

+ 16
- 7
src/main/org/apache/tools/ant/taskdefs/Mkdir.java View File

@@ -54,9 +54,10 @@


package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import java.io.File; import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.DestDir;




/** /**
@@ -74,10 +75,6 @@ public class Mkdir extends Task {
throw new BuildException("dir attribute is required", location); throw new BuildException("dir attribute is required", location);
} }


if (dir.isFile()) {
throw new BuildException("Unable to create directory as a file already exists with that name: " + dir.getAbsolutePath());
}

if (!dir.exists()) { if (!dir.exists()) {
boolean result = dir.mkdirs(); boolean result = dir.mkdirs();
if (result == false) { if (result == false) {
@@ -89,7 +86,19 @@ public class Mkdir extends Task {
} }
} }


/**
* @deprecated setDir(File) is deprecated and is replaced with
* setDir(DestDir) to let Ant's core perform validation
*/
public void setDir(File dir) { public void setDir(File dir) {
this.dir = dir;
log("DEPRECATED - The setDir(File) method has been deprecated."
+ " Use setDir(DestDir) instead.");
DestDir destDir = new DestDir();
destDir.setFile(dir);
setDir(destDir);
}

public void setDir(DestDir destDir) {
this.dir = destDir.getFile();
} }
} }

Loading…
Cancel
Save