workDir, catalinaHomePath, getName()), e);
}
}
- if (!dir.exists() && !dir.mkdirs()) {
+ if (!dir.mkdirs() && !dir.isDirectory()) {
log.warn(sm.getString("standardContext.workCreateFail", dir,
getName()));
}
throw new IllegalArgumentException(
sm.getString("webappClassLoader.validationErrorJarPath",
jarEntry2.getName()), ioe);
- }
- resourceFile.getParentFile().mkdirs();
+ }
+ File parentFile = resourceFile.getParentFile();
+ if (!parentFile.mkdirs() && !parentFile.exists()) {
+ // Ignore the error (like the IOExceptions below)
+ }
FileOutputStream os = null;
InputStream is = null;
try {
} else {
classRepository = new File(workDir, classesPath);
- if (!classRepository.isDirectory()) {
- if (!classRepository.mkdirs())
- throw new IOException(
- sm.getString("webappLoader.mkdirFailure"));
+ if (!classRepository.mkdirs() &&
+ !classRepository.isDirectory()) {
+ throw new IOException(
+ sm.getString("webappLoader.mkdirFailure"));
}
if (!copyDir(classes, classRepository)) {
throw new IOException(
} else {
copyJars = true;
destDir = new File(workDir, libPath);
- if (!destDir.isDirectory()) {
- if (!destDir.mkdirs())
- throw new IOException(
- sm.getString("webappLoader.mkdirFailure"));
+ if (!destDir.mkdirs() && !destDir.isDirectory()) {
+ throw new IOException(
+ sm.getString("webappLoader.mkdirFailure"));
}
}
File deployedPath = deployed;
if (tag != null) {
deployedPath = new File(versioned, tag);
- if (!deployedPath.isDirectory() && !deployedPath.mkdirs()) {
+ if (!deployedPath.mkdirs() && !deployedPath.isDirectory()) {
writer.println(smClient.getString("managerServlet.mkdirFail",
deployedPath));
return;
addServiced(name);
try {
if (config != null) {
- if (!configBase.isDirectory() && !configBase.mkdirs()) {
+ if (!configBase.mkdirs() && !configBase.isDirectory()) {
writer.println(smClient.getString(
"managerServlet.mkdirFail",configBase));
return;
} catch (IOException e) {
appBaseFile = file;
}
- if (!appBaseFile.exists()) {
- if (!appBaseFile.mkdirs()) {
- writer.println(smClient.getString(
- "hostManagerServlet.appBaseCreateFail",
- appBaseFile.toString(), name));
- return;
- }
+ if (!appBaseFile.mkdirs() && !appBaseFile.isDirectory()) {
+ writer.println(smClient.getString(
+ "hostManagerServlet.appBaseCreateFail",
+ appBaseFile.toString(), name));
+ return;
}
// Create base for config files
if (installedHost != null) {
configBase = new File(configBase, hostName);
}
- if (!configBase.exists()) {
- if (!configBase.mkdirs()) {
- return null;
- }
+ if (!configBase.mkdirs() && !configBase.isDirectory()) {
+ return null;
}
return configBase;
}
String dirPath = destPath.toString().substring(
0,destPath.toString().lastIndexOf("/"));
File dir = new File(dirPath);
- if (!dir.mkdirs() && debug >= 2) {
- log("expandCGIScript: failed to create directories for '" +
- dir.getAbsolutePath() + "'");
+ if (!dir.mkdirs() && !dir.isDirectory()) {
+ if (debug >= 2) {
+ log("expandCGIScript: failed to create directories for '" +
+ dir.getAbsolutePath() + "'");
+ }
return;
}
* session persistence directory, if any. The directory will be
* created if it does not already exist.
*/
- private File directory() {
+ private File directory() throws IOException {
if (this.directory == null) {
return (null);
}
}
if (!file.exists() || !file.isDirectory()) {
- file.delete();
- file.mkdirs();
+ if (!file.delete() && file.exists()) {
+ throw new IOException(
+ sm.getString("fileStore.deleteFailed", file));
+ }
+ if (!file.mkdirs() && !file.isDirectory()) {
+ throw new IOException(
+ sm.getString("fileStore.createFailed", file));
+ }
}
this.directoryFile = file;
return (file);
* @param id The ID of the Session to be retrieved. This is
* used in the file naming.
*/
- private File file(String id) {
+ private File file(String id) throws IOException {
if (this.directory == null) {
return (null);
fileStore.saving=Saving Session {0} to file {1}
fileStore.loading=Loading Session {0} from file {1}
fileStore.removing=Removing Session {0} at file {1}
+fileStore.deleteFailed=Unable to delete file [{0}] which is preventing the creation of the session storage location
+fileStore.createFailed=Unable to create directory [{0}] for the storage of session data
JDBCStore.close=Exception closing database connection {0}
JDBCStore.saving=Saving Session {0} to database {1}
JDBCStore.loading=Loading Session {0} from database {1}
if (last >= 0) {
File parent = new File(docBase,
name.substring(0, last));
- parent.mkdirs();
+ if (!parent.mkdirs() && !parent.isDirectory()) {
+ throw new IOException(
+ sm.getString("expandWar.createFailed", parent));
+ }
}
if (name.endsWith("/")) {
continue;
if (host.getCreateDirs()) {
File[] dirs = new File[] {host.getAppBaseFile(),configBase()};
for (int i=0; i<dirs.length; i++) {
- if ( (!dirs[i].isDirectory()) && (!dirs[i].mkdirs())) {
+ if (!dirs[i].mkdirs() && !dirs[i].isDirectory()) {
log.error(sm.getString("hostConfig.createDirs",dirs[i]));
}
}
engineConfig.start=EngineConfig: Processing START
engineConfig.stop=EngineConfig: Processing STOP
expandWar.copy=Error copying {0} to {1}
+expandWar.createFailed=Unable to create the directory [{0}]
expandWar.deleteFailed=[{0}] could not be completely deleted. The presence of the remaining files may cause problems
expandWar.illegalPath=The archive [{0}] is malformed and will be ignored: an entry contains an illegal path [{1}] which was not expanded to [{2}] since that is outside of the defined docBase [{3}]
hostConfig.appBase=Application base [{1}] for host [{0}] does not exist or is not a directory. deployOnStartUp and autoDeploy have been set to false to prevent deployment errors. Other errors may still occur.
File dir = new File(directory);
if (!dir.isAbsolute())
dir = new File(System.getProperty(Globals.CATALINA_BASE_PROP), directory);
- if (!dir.exists()) {
- if (!dir.mkdirs()) {
- log.error(sm.getString("accessLogValve.openDirFail", dir));
- }
+ if (!dir.mkdirs() && !dir.isDirectory()) {
+ log.error(sm.getString("accessLogValve.openDirFail", dir));
}
// Open the current log file
pathname = new File(dir.getAbsoluteFile(), prefix + suffix);
}
File parent = pathname.getParentFile();
- if (!parent.exists()) {
- if (!parent.mkdirs()) {
- log.error(sm.getString("accessLogValve.openDirFail", parent));
- }
+ if (!parent.mkdirs() && !parent.isDirectory()) {
+ log.error(sm.getString("accessLogValve.openDirFail", parent));
}
Charset charset = null;
protected boolean makeOutputDir() {
synchronized(outputDirLock) {
File outDirFile = new File(outputDir);
- return (outDirFile.exists() || outDirFile.mkdirs());
+ return (outDirFile.mkdirs() || outDirFile.isDirectory());
}
}
// Create the directory if necessary
File dir = new File(directory);
- if (!dir.exists() && !dir.mkdirs()) {
+ if (!dir.mkdirs() && !dir.isDirectory()) {
reportError("Unable to create [" + dir + "]", null,
ErrorManager.OPEN_FAILURE);
writer = null;
File pathname = new File(dir.getAbsoluteFile(), prefix
+ (rotatable ? date : "") + suffix);
File parent = pathname.getParentFile();
- if (!parent.exists()) {
- if (!parent.mkdirs()) {
- reportError("Unable to create [" + parent + "]", null,
- ErrorManager.OPEN_FAILURE);
- writer = null;
- return;
- }
+ if (!parent.mkdirs() && !parent.isDirectory()) {
+ reportError("Unable to create [" + parent + "]", null,
+ ErrorManager.OPEN_FAILURE);
+ writer = null;
+ return;
}
String encoding = getEncoding();
FileOutputStream fos = new FileOutputStream(pathname, true);
// Create the folder that will trigger the redirect
File foo = new File(docBase, "foo");
- if (!foo.exists() && !foo.mkdirs()) {
+ if (!foo.mkdirs() && !foo.isDirectory()) {
fail("Unable to create foo directory in docBase");
}
// Create the folder that will trigger the redirect
File foo = new File(docBase, "async");
- if (!foo.exists() && !foo.mkdirs()) {
+ if (!foo.mkdirs() && !foo.isDirectory()) {
fail("Unable to create async directory in docBase");
}
Tomcat tomcat = getTomcatInstance();
File docBase = new File(tomcat.getHost().getAppBaseFile(), "ROOT");
- if (!docBase.exists() && !docBase.mkdirs()) {
+ if (!docBase.mkdirs() && !docBase.isDirectory()) {
fail("Unable to create docBase");
}
public void testCustomErrorPage() throws Exception {
File appDir = new File(getTemporaryDirectory(), "MyApp");
File webInf = new File(appDir, "WEB-INF");
- if (!webInf.mkdirs()) {
+ if (!webInf.mkdirs() && !webInf.isDirectory()) {
fail("Unable to create directory [" + webInf + "]");
}
Writer w = new OutputStreamWriter(new FileOutputStream(new File(appDir,
public void testCustomErrorPageMissing() throws Exception {
File appDir = new File(getTemporaryDirectory(), "MyApp");
File webInf = new File(appDir, "WEB-INF");
- if (!webInf.mkdirs()) {
+ if (!webInf.mkdirs() && !webInf.isDirectory()) {
fail("Unable to create directory [" + webInf + "]");
}
Writer w = new OutputStreamWriter(new FileOutputStream(new File(appDir,
getBuildDirectory(), "conf/logging.properties").toString());
tempDir = new File(System.getProperty("tomcat.test.temp", "output/tmp"));
- if (!tempDir.exists() && !tempDir.mkdirs()) {
+ if (!tempDir.mkdirs() && !tempDir.isDirectory()) {
fail("Unable to create temporary directory for test");
}