1 28 29 package com.idaremedia.antx.mktemp; 30 31 import java.io.File ; 32 33 import org.apache.tools.ant.BuildException; 34 import org.apache.tools.ant.Project; 35 36 import com.idaremedia.antx.Iteration; 37 import com.idaremedia.antx.apis.Requester; 38 import com.idaremedia.antx.parameters.FeedbackLevel; 39 40 50 51 final class Mkdirs 52 { 53 64 static boolean run(File dir, boolean haltiferror, FeedbackLevel fb, Requester clnt) 65 throws BuildException 66 { 67 boolean okidoki=true; 68 if (!dir.exists()) { 69 try { 70 dir.mkdirs(); 71 if (fb.getIndex()<FeedbackLevel.QUIET_INDEX) { 72 clnt.log("Directory created: "+dir.getPath(), 73 Project.MSG_INFO); 74 } 75 } 76 catch (SecurityException secX) { 77 String message = Iteration.uistrs().get("task.cant.access.dir", 78 dir.getPath()); 79 if (haltiferror) { 80 clnt.problem(message, Project.MSG_ERR); 81 throw new BuildException(message, secX, clnt.getLocation()); 82 } 83 if (fb.getIndex()<FeedbackLevel.QUIET_INDEX) { clnt.problem(message, Project.MSG_WARN); 85 } 86 okidoki=false; 87 } 88 } 89 else if (!dir.isDirectory() || !dir.canWrite() || !dir.canRead()) { 90 String message; 91 if (!dir.isDirectory()) { 92 message = "mktemp.mkdirs.file.exists"; 93 } else { 94 message = "task.cant.access.dir"; 95 } 96 message = Iteration.uistrs().get(message,dir.getPath()); 97 if (haltiferror) { 98 clnt.problem(message, Project.MSG_ERR); 99 throw new BuildException(message, clnt.getLocation()); 100 } 101 if (fb.getIndex()<=FeedbackLevel.QUIET_INDEX) { clnt.problem(message, Project.MSG_WARN); 103 } 104 okidoki=false; 105 } 106 return okidoki; 107 } 108 109 110 private Mkdirs() 111 { 112 } 113 } 114 115 116 | Popular Tags |