Does the actual validation
@param directory the directory to validate
@param option validation options
516170
protected void validate(File directory, ValidationOptions option){
		if(!directory.exists()){
			this.errors.addError("directory <{}> does not exist in file system", directory.getAbsolutePath());
		}
		else if(!directory.isDirectory()){
			this.errors.addError("directory <{}> is not a directory", directory.getAbsolutePath());
		}
		else if(directory.isHidden()){
			this.errors.addError("directory <{}> is a hidden directory", directory.getAbsolutePath());
		}
		else{
			switch(option){
				case AS_SOURCE:
					if(!directory.canRead()){
						this.errors.addError("directory <{}> is not readable", directory.getAbsolutePath());
					}
					break;
				case AS_SOURCE_AND_TARGET:
					if(!directory.canRead()){
						this.errors.addError("directory <{}> is not readable", directory.getAbsolutePath());
					}
					if(!directory.canWrite()){
						this.errors.addError("directory <{}> is not writable", directory.getAbsolutePath());
					}
					break;
				case AS_TARGET:
					if(!directory.canWrite()){
						this.errors.addError("directory <{}> is not writable", directory.getAbsolutePath());
					}
					break;
			}
		}
	}
542359
public void setCompileDirectory(String directory) {
        if (directory != null && directory.trim().length() > 0) {
            File file = new File(directory);
            if (file.exists() || file.mkdirs()) {
                this.compileDirectory = file;
            }
        }
    }
79873
public static boolean createOrCleanDirectory(String directory) {
    // if the directory does not exist, create it.
    if (!FileUtils.isDirectoryExists(directory)) {
      LOG.fine("The directory does not exist; creating it.");
      if (!FileUtils.createDirectory(directory)) {
        LOG.severe("Failed to create directory: " + directory);
        return false;
      }
    }

    // Cleanup the directory
    if (!FileUtils.cleanDir(directory)) {
      LOG.severe("Failed to clean directory: " + directory);
      return false;
    }

    return true;
  }
334028
private void checkDirectory(String d) {
    if (!d.startsWith(Path.SEPARATOR)) {
      throw new IllegalArgumentException("Bad directory:" + d);
    }
    if (d.endsWith(Path.SEPARATOR)) {
      throw new IllegalArgumentException("Bad directory:" + d);
    }
  }
830680
@Override
	public boolean cd(String directory) {
		if (StrUtil.isBlank(directory)) {
			// 当前目录
			return true;
		}
		try {
			channel.cd(directory.replaceAll("\\\\", "/"));
			return true;
		} catch (SftpException e) {
			return false;
		}
	}
1221189
public static void directoryCheck(String dir) throws IOException {
		final File file = new File(dir);

		if (!file.exists()) {
			FileUtils.forceMkdir(file);
		}
	}
790066
public void setDir(java.lang.String dir) {
        getStateHelper().put(PropertyKeys.dir, dir);
        handleAttribute("dir", dir);
    }
480329
def valid_directory?(entry)
      File.directory?(source.join(entry)) && !IGNORE_DIR.include?(File.basename(entry))
    end
1147810
protected void validate(File file, ValidationOptions option){
		if(!file.exists()){
			this.errors.addError("file <{}> does not exist in file system", file.getAbsolutePath());
		}
		else if(!file.isFile()){
			this.errors.addError("file <{}> is not a file", file.getAbsolutePath());
		}
		if(file.isHidden()){
			this.errors.addError("file <{}> is a hidden file", file.getAbsolutePath());
		}
		else{
			switch(option){
				case AS_SOURCE:
					if(!file.canRead()){
						this.errors.addError("file <{}> is not readable", file.getAbsolutePath());
					}
					break;
				case AS_SOURCE_AND_TARGET:
					if(!file.canRead()){
						this.errors.addError("file <{}> is not readable", file.getAbsolutePath());
					}
					if(!file.canWrite()){
						this.errors.addError("file <{}> is not writable", file.getAbsolutePath());
					}
					break;
				case AS_TARGET:
					if(!file.canWrite()){
						this.errors.addError("file <{}> is not writable", file.getAbsolutePath());
					}
					break;
			}
		}
	}
187127
async function validateOptions(options) {
  // Check that input glob was passed
  if (!options.paths.length) {
    throw new ValidationError('No paths specified')
  }

  // Check that output path was passed
  if (!options.outputDir) {
    throw new ValidationError('Please specify an output directory with -o or --output')
  }

  // Check that the existance of output path
  if (!await fsAsync.exists(options.outputDir)) {
    throw new ValidationError('Output directory doesn\'t exist')
  }

  // Check that output path is a directory
  const outStat = await fsAsync.stat(options.outputDir)
  if (!outStat.isDirectory()) {
    throw new ValidationError('Output path must be a directory')
  }

  // Check existance of CSS template (If set)
  if (options.cssTemplate && !await fsAsync.exists(options.cssTemplate)) {
    throw new ValidationError('CSS template not found')
  }

  // Check existance of HTML template (If set)
  if (options.htmlTemplate && !await fsAsync.exists(options.htmlTemplate)) {
    throw new ValidationError('HTML template not found')
  }

  // Validate codepoints file if passed
  if (options.codepoints) {
    if (!await fsAsync.exists(options.codepoints)) {
      throw new ValidationError(`Cannot find json file @ ${options.codepoints}!`)
    }

    const codepointsStat = await fsAsync.stat(options.codepoints)
    if (!codepointsStat.isFile() || path.extname(options.codepoints) !== '.json') {
      throw new ValidationError([
        'Codepoints file must be JSON',
        `${options.codepoints} is not a valid file.`
      ].join(' '))
    }
  }
}
1327630
public boolean validate() {
        JavaFileManager fm = getFileManager();
        if (options.isSet(Option.MODULE)) {
            if (!fm.hasLocation(StandardLocation.CLASS_OUTPUT)) {
                log.error(Errors.OutputDirMustBeSpecifiedWithDashMOption);
            } else if (!fm.hasLocation(StandardLocation.MODULE_SOURCE_PATH)) {
                log.error(Errors.ModulesourcepathMustBeSpecifiedWithDashMOption);
            } else {
                java.util.List<String> modules = Arrays.asList(options.get(Option.MODULE).split(","));
                try {
                    for (String module : modules) {
                        Location sourceLoc = fm.getLocationForModule(StandardLocation.MODULE_SOURCE_PATH, module);
                        if (sourceLoc == null) {
                            log.error(Errors.ModuleNotFoundInModuleSourcePath(module));
                        } else {
                            Location classLoc = fm.getLocationForModule(StandardLocation.CLASS_OUTPUT, module);

                            for (JavaFileObject file : fm.list(sourceLoc, "", EnumSet.of(JavaFileObject.Kind.SOURCE), true)) {
                                String className = fm.inferBinaryName(sourceLoc, file);
                                JavaFileObject classFile = fm.getJavaFileForInput(classLoc, className, Kind.CLASS);

                                if (classFile == null || classFile.getLastModified() < file.getLastModified()) {
                                    if (fileObjects == null)
                                        fileObjects = new HashSet<>();
                                    fileObjects.add(file);
                                }
                            }
                        }
                    }
                } catch (IOException ex) {
                    log.printLines(PrefixKind.JAVAC, "msg.io");
                    ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
                    return false;
                }
            }
        }

        if (isEmpty()) {
            // It is allowed to compile nothing if just asking for help or version info.
            // But also note that none of these options are supported in API mode.
            if (options.isSet(Option.HELP)
                    || options.isSet(Option.X)
                    || options.isSet(Option.VERSION)
                    || options.isSet(Option.FULLVERSION)
                    || options.isSet(Option.MODULE)) {
                return true;
            }

            if (!emptyAllowed) {
                if (!errors) {
                    if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
                        error("err.no.source.files.classes");
                    } else {
                        error("err.no.source.files");
                    }
                }
                return false;
            }
        }

        if (!checkDirectory(Option.D)) {
            return false;
        }
        if (!checkDirectory(Option.S)) {
            return false;
        }
        if (!checkDirectory(Option.H)) {
            return false;
        }

        // The following checks are to help avoid accidental confusion between
        // directories of modules and exploded module directories.
        if (fm instanceof StandardJavaFileManager) {
            StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
            if (sfm.hasLocation(StandardLocation.CLASS_OUTPUT)) {
                Path outDir = sfm.getLocationAsPaths(StandardLocation.CLASS_OUTPUT).iterator().next();
                if (sfm.hasLocation(StandardLocation.MODULE_SOURCE_PATH)) {
                    // multi-module mode
                    if (Files.exists(outDir.resolve("module-info.class"))) {
                        log.error(Errors.MultiModuleOutdirCannotBeExplodedModule(outDir));
                    }
                } else {
                    // single-module or legacy mode
                    boolean lintPaths = options.isUnset(Option.XLINT_CUSTOM,
                            "-" + LintCategory.PATH.option);
                    if (lintPaths) {
                        Path outDirParent = outDir.getParent();
                        if (outDirParent != null && Files.exists(outDirParent.resolve("module-info.class"))) {
                            log.warning(LintCategory.PATH, Warnings.OutdirIsInExplodedModule(outDir));
                        }
                    }
                }
            }
        }


        String sourceString = options.get(Option.SOURCE);
        Source source = (sourceString != null)
                ? Source.lookup(sourceString)
                : Source.DEFAULT;
        String targetString = options.get(Option.TARGET);
        Target target = (targetString != null)
                ? Target.lookup(targetString)
                : Target.DEFAULT;

        // We don't check source/target consistency for CLDC, as J2ME
        // profiles are not aligned with J2SE targets; moreover, a
        // single CLDC target may have many profiles.  In addition,
        // this is needed for the continued functioning of the JSR14
        // prototype.
        if (Character.isDigit(target.name.charAt(0))) {
            if (target.compareTo(source.requiredTarget()) < 0) {
                if (targetString != null) {
                    if (sourceString == null) {
                        error("warn.target.default.source.conflict",
                                targetString,
                                source.requiredTarget().name);
                    } else {
                        error("warn.source.target.conflict",
                                sourceString,
                                source.requiredTarget().name);
                    }
                    return false;
                } else {
                    target = source.requiredTarget();
                    options.put("-target", target.name);
                }
            }
        }

        String profileString = options.get(Option.PROFILE);
        if (profileString != null) {
            Profile profile = Profile.lookup(profileString);
            if (!profile.isValid(target)) {
                error("warn.profile.target.conflict", profileString, target.name);
            }

            // This check is only effective in command line mode,
            // where the file manager options are added to options
            if (options.get(Option.BOOT_CLASS_PATH) != null) {
                error("err.profile.bootclasspath.conflict");
            }
        }

        if (options.isSet(Option.SOURCE_PATH) && options.isSet(Option.MODULE_SOURCE_PATH)) {
            error("err.sourcepath.modulesourcepath.conflict");
        }

        boolean lintOptions = options.isUnset(Option.XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option);
        if (lintOptions && source.compareTo(Source.DEFAULT) < 0 && !options.isSet(Option.RELEASE)) {
            if (fm instanceof BaseFileManager) {
                if (((BaseFileManager) fm).isDefaultBootClassPath())
                    log.warning(LintCategory.OPTIONS, "source.no.bootclasspath", source.name);
            }
        }

        boolean obsoleteOptionFound = false;

        if (source.compareTo(Source.MIN) < 0) {
            log.error(Errors.OptionRemovedSource(source.name, Source.MIN.name));
        } else if (source == Source.MIN && lintOptions) {
            log.warning(LintCategory.OPTIONS, Warnings.OptionObsoleteSource(source.name));
            obsoleteOptionFound = true;
        }

        if (target.compareTo(Target.MIN) < 0) {
            log.error(Errors.OptionRemovedTarget(target.name, Target.MIN.name));
        } else if (target == Target.MIN && lintOptions) {
            log.warning(LintCategory.OPTIONS, Warnings.OptionObsoleteTarget(target.name));
            obsoleteOptionFound = true;
        }

        final Target t = target;
        checkOptionAllowed(t.compareTo(Target.JDK1_8) <= 0,
                option -> error("err.option.not.allowed.with.target", option.getPrimaryName(), t.name),
                Option.BOOT_CLASS_PATH,
                Option.XBOOTCLASSPATH_PREPEND, Option.XBOOTCLASSPATH, Option.XBOOTCLASSPATH_APPEND,
                Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
                Option.EXTDIRS, Option.DJAVA_EXT_DIRS,
                Option.PROFILE);

        checkOptionAllowed(t.compareTo(Target.JDK1_9) >= 0,
                option -> error("err.option.not.allowed.with.target", option.getPrimaryName(), t.name),
                Option.MODULE_SOURCE_PATH, Option.UPGRADE_MODULE_PATH,
                Option.SYSTEM, Option.MODULE_PATH, Option.ADD_MODULES,
                Option.ADD_EXPORTS, Option.ADD_OPENS, Option.ADD_READS,
                Option.LIMIT_MODULES,
                Option.PATCH_MODULE);

        if (fm.hasLocation(StandardLocation.MODULE_SOURCE_PATH)) {
            if (!options.isSet(Option.PROC, "only")
                    && !fm.hasLocation(StandardLocation.CLASS_OUTPUT)) {
                log.error(Errors.NoOutputDir);
            }
        }

        if (fm.hasLocation(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH) &&
            fm.hasLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH)) {
            log.error(Errors.ProcessorpathNoProcessormodulepath);
        }

        if (obsoleteOptionFound && lintOptions) {
            log.warning(LintCategory.OPTIONS, "option.obsolete.suppression");
        }

        SourceVersion sv = Source.toSourceVersion(source);
        validateAddExports(sv);
        validateAddModules(sv);
        validateAddReads(sv);
        validateLimitModules(sv);
        validateDefaultModuleForCreatedFiles(sv);

        if (lintOptions && options.isSet(Option.ADD_OPENS)) {
            log.warning(LintCategory.OPTIONS, Warnings.AddopensIgnored);
        }

        return !errors && (log.nerrors == 0);
    }
902518
public static void deleteDirectory(File directory) throws IOException {
    requireNonNull(directory, DIRECTORY_CAN_NOT_BE_NULL);

    if (!directory.exists()) {
      return;
    }

    Path path = directory.toPath();
    if (Files.isSymbolicLink(path)) {
      throw new IOException(format("Directory '%s' is a symbolic link", directory));
    }
    if (directory.isFile()) {
      throw new IOException(format("Directory '%s' is a file", directory));
    }
    deleteDirectoryImpl(path);

    if (directory.exists()) {
      throw new IOException(format("Unable to delete directory '%s'", directory));
    }
  }
786090
private void validateSettingsDir() {
         if (!settingsDir.exists()) {
             throw new RuntimeException(SETTINGS_DIR_OPTION + " : " + settingsDir.getPath() + " does not exist!");
         }
         else if (!settingsDir.isDirectory()) {
             throw new RuntimeException(SETTINGS_DIR_OPTION + " : " + settingsDir.getPath() + " is not a directory!");
         }
     }
770356
private void directorySanityChecks(File directory) {

    if (!directory.exists())
      throw new VOMSError("Local trust directory does not exists:"
        + directory.getAbsolutePath());

    if (!directory.isDirectory())
      throw new VOMSError("Local trust directory is not a directory:"
        + directory.getAbsolutePath());

    if (!directory.canRead())
      throw new VOMSError("Local trust directory is not readable:"
        + directory.getAbsolutePath());

    if (!directory.canExecute())
      throw new VOMSError("Local trust directory is not traversable:"
        + directory.getAbsolutePath());

  }
838830
public static void deleteDirectory(File directory) throws IOException {
    requireNonNull(directory, DIRECTORY_CAN_NOT_BE_NULL);
    deleteDirectoryImpl(directory.toPath());
  }
713012
protected void validate() {
    // make sure that the source uri is set correctly.
    if (mSourceUri == null) {
      throw new BuilderException("Source must be set!");
    }

    // For local resource we require caller to specify statically generated resource id as a path.
    if (UriUtil.isLocalResourceUri(mSourceUri)) {
      if (!mSourceUri.isAbsolute()) {
        throw new BuilderException("Resource URI path must be absolute.");
      }
      if (mSourceUri.getPath().isEmpty()) {
        throw new BuilderException("Resource URI must not be empty");
      }
      try {
        Integer.parseInt(mSourceUri.getPath().substring(1));
      } catch (NumberFormatException ignored) {
        throw new BuilderException("Resource URI path must be a resource id.");
      }
    }

    // For local asset we require caller to specify absolute path of an asset, which will be
    // resolved by AssetManager relative to configured asset folder of an app.
    if (UriUtil.isLocalAssetUri(mSourceUri) && !mSourceUri.isAbsolute()) {
      throw new BuilderException("Asset URI path must be absolute.");
    }
  }
660076
private boolean directoryContains(File directory, IGroupMember member) {
        boolean found = false;
        if (member.isGroup()) {
            File memberFile = getFile((IEntityGroup) member);
            File[] files = directory.listFiles();
            for (int i = 0; i < files.length & !found; i++) {
                found = files[i].equals(memberFile);
            }
        }
        return found;
    }