} finally {
wcAccess.close();
}
}
SVNFileType kind = SVNFileType.getType(path);
if (force && mkdir && kind == SVNFileType.DIRECTORY) {
// directory is already there.
doAdd(path, force, false, true, SVNDepth.EMPTY, depthIsSticky, true, makeParents);
return;
} else if (mkdir) {
// attempt to create dir
File parent = path;
File firstCreated = path;
while (parent != null && SVNFileType.getType(parent) == SVNFileType.NONE) {
if (!parent.equals(path) && !makeParents) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR,
"Cannot create directoy ''{0}'' with non-existent parents", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
firstCreated = parent;
parent = parent.getParentFile();
}
boolean created = path.mkdirs();
if (!created) {
// delete created dirs.
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR,
"Cannot create new directory ''{0}''", path);
while (parent == null ? path != null : !path.equals(parent)) {
SVNFileUtil.deleteAll(path, true);
path = path.getParentFile();
}
SVNErrorManager.error(err, SVNLogType.WC);
}
try {
doAdd(firstCreated, false, false, climbUnversionedParents, depth, depthIsSticky, true, makeParents);
} catch (SVNException e) {
SVNFileUtil.deleteAll(firstCreated, true);
throw e;
}
return;
}
SVNWCAccess wcAccess = createWCAccess();
try {
SVNAdminArea dir = null;
SVNFileType fileType = SVNFileType.getType(path);
if (fileType == SVNFileType.DIRECTORY) {
dir = wcAccess.open(SVNWCUtil.isVersionedDirectory(path.getParentFile()) ? path.getParentFile() : path, true, 0);
} else {
// files and symlink goes here.
dir = wcAccess.open(path.getParentFile(), true, 0);