import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; //导入方法依赖的package包/类
private static StatusInfo validatePathName(String str, IContainer parent) {
StatusInfo result= new StatusInfo();
result.setOK();
IPath parentPath= parent.getFullPath();
if (str.length() == 0) {
result.setError(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_error_EnterRootName, BasicElementLabels.getPathLabel(parentPath, false)));
return result;
}
IPath path= parentPath.append(str);
IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
IStatus validate= workspaceRoot.getWorkspace().validatePath(path.toString(), IResource.FOLDER);
if (validate.matches(IStatus.ERROR)) {
result.setError(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_error_InvalidRootName, validate.getMessage()));
return result;
}
IResource res= workspaceRoot.findMember(path);
if (res != null) {
if (res.getType() != IResource.FOLDER) {
result.setError(NewWizardMessages.NewSourceFolderWizardPage_error_NotAFolder);
return result;
}
} else {
URI parentLocation= parent.getLocationURI();
if (parentLocation != null) {
try {
IFileStore store= EFS.getStore(parentLocation).getChild(str);
if (store.fetchInfo().exists()) {
result.setError(NewWizardMessages.NewSourceFolderWizardPage_error_AlreadyExistingDifferentCase);
return result;
}
} catch (CoreException e) {
// we couldn't create the file store. Ignore the exception
// since we can't check if the file exist. Pretend that it
// doesn't.
}
}
}
return result;
}