called from the catch clauses in checkNodeDirectory
188507
private final void cleanupAfterExceptionDuringNodeDirCheck() {
        if (nodeDirectory != null) {
            // attempt to remove the node directory
            try {
                if (session.exists(nodeDirectory, this)) {
                    session.rmdir(nodeDirectory);
                }
                nodeDirectory = null;
            } catch (final ClusterInfoException cie2) {}
        }
    }
145872
private void validate(QPath path) throws RepositoryException, AccessDeniedException, ReferentialIntegrityException
   {

      List<ItemState> changes = changesLog.getAllStates();
      for (ItemState itemState : changes)
      {

         if (itemState.isInternallyCreated())
         {
            // skip internally created
            if (itemState.isMixinChanged())
            {
               // ...except of check of ACL correct size for internally created
               // items.
               // If no permissions in the list throw exception.
               if (itemState.isDescendantOf(path))
               {
                  if (((NodeData)itemState.getData()).getACL().getPermissionsSize() < 1)
                  {
                     throw new RepositoryException("Node " + itemState.getData().getQPath().getAsString()
                        + " has wrong formed ACL.");
                  }
               }
               validateMandatoryItem(itemState);
            }
         }
         else
         {
            if (itemState.isDescendantOf(path))
            {
               validateAccessPermissions(itemState);
               validateMandatoryItem(itemState);
            }

            if (path.isDescendantOf(itemState.getAncestorToSave()))
            {
               throw new ConstraintViolationException(path.getAsString()
                  + " is the same or descendant of either Session.move()'s destination or source node only "
                  + path.getAsString());
            }
         }
      }
   }
697061
void fileWriteCheck(String filePath, AddOnModel addOnModel) {
        File request;
        try {
            request =  new File(filePath).getCanonicalFile();
        } catch (IOException e) {
            error("Error getting canonical path", e);
            throw getException(filePath);
        }

        isForbidden(request, addOnModel);

        boolean success = false;
        if (allowedWriteDirectories.stream()
                .anyMatch(compare -> request.toPath().startsWith(compare.toPath()))) {
            success = true;
        }

        for (String name : forbiddenWriteFilesNames) {
            if (request.getName().equals(name)) {
                success = false;
            }
        }

        if (!success) {
            throw getException(filePath);
        }

        if (!getSecurityManager().getSecureAccess().checkForExistingFileOrDirectory(request.toString())
                || getSecurityManager().getSecureAccess().checkForDirectory(request.toString())) {
            return;
        }
    }
485310
private void checkDirectory(File d, String dtype) {

        if (!d.isAbsolute()) {
            throw new IllegalArgumentException(dtype
                    + " directory must be an absolute path (" + d.getPath() + ")");
        }
        if (!d.exists()) {
            throw new IllegalArgumentException(dtype
                    + " directory does not exist (" + d.getPath() + ")");
        }
        if (!d.isDirectory()) {
            throw new IllegalArgumentException(dtype
                    + " directory value is not a directory (" + d.getPath() + ")");
        }

    }
1158321
function(inNode) {
		var t, n = inNode;
		// FIXME: Mozilla: try/catch is here to squelch "Permission denied to access property xxx from a non-chrome context" 
		// which appears to happen for scrollbar nodes in particular. It's unclear why those nodes are valid targets if 
		// it is illegal to interrogate them. Would like to trap the bad nodes explicitly rather than using an exception block.
		try {
			while (n) {
				if (t = enyo.$[n.id]) {
					// there could be multiple nodes with this id, the relevant node for this event is n
					// we don't push this directly to t.node because sometimes we are just asking what
					// the target 'would be' (aka, calling findDispatchTarget from handleMouseOverOut)
					t.eventNode = n;
					break;
				}
				n = n.parentNode;
			}
		} catch(x) {
			console.log(x, n);
		}
		return t;
	}
878661
private static void checkSrcPath(Configuration conf, List<Path> srcPaths
      ) throws IOException {
    List<IOException> rslt = new ArrayList<IOException>();
    List<Path> unglobbed = new LinkedList<Path>();
    for (Path p : srcPaths) {
      FileSystem fs = p.getFileSystem(conf);
      FileStatus[] inputs = fs.globStatus(p);

      if(inputs != null && inputs.length > 0) {
        for (FileStatus onePath: inputs) {
          unglobbed.add(onePath.getPath());
        }
      } else {
        rslt.add(new IOException("Input source " + p + " does not exist."));
      }
    }
    if (!rslt.isEmpty()) {
      throw new InvalidInputException(rslt);
    }
    srcPaths.clear();
    srcPaths.addAll(unglobbed);
  }
521429
private void validate(File root, Collection<URI> dirs) throws IOException {
    if (dirs == null)
      return;
    for (URI dir : dirs) {
      if (new File(dir.getPath()).getAbsolutePath().equals(
          root.getAbsolutePath())) {
        // we found the corresponding entry
        return;
      }
    }
    throwIOException("Error. Storage directory: " + root
        + " is not in the configured list of storage directories: " + dirs);
  }
108592
def check_dir(directory, newly_created_files):
  """"""
  header_parse_failures = []
  for root, dirs, files in os.walk(directory):
    for f in files:
      if f.endswith('.py') and os.path.basename(f) != '__init__.py':
        filename = os.path.join(root, f)
        try:
          check_header(filename, filename in newly_created_files)
        except HeaderCheckFailure as e:
          header_parse_failures.append(e.message)
  return header_parse_failures
667999
private void checkDeletable(File file, DeleteMode mode, Path path) throws IOException {
    if (file.isRootDirectory()) {
      throw new FileSystemException(path.toString(), null, "can't delete root directory");
    }

    if (file.isDirectory()) {
      if (mode == DeleteMode.NON_DIRECTORY_ONLY) {
        throw new FileSystemException(path.toString(), null, "can't delete: is a directory");
      }

      checkEmpty(((Directory) file), path);
    } else if (mode == DeleteMode.DIRECTORY_ONLY) {
      throw new FileSystemException(path.toString(), null, "can't delete: is not a directory");
    }

    if (file == workingDirectory && !path.isAbsolute()) {
      // this is weird, but on Unix at least, the file system seems to be happy to delete the
      // working directory if you give the absolute path to it but fail if you use a relative path
      // that resolves to the working directory (e.g. "" or ".")
      throw new FileSystemException(path.toString(), null, "invalid argument");
    }
  }
1322336
private void checkl() throws DatatypeException, IOException {
        if (context.length() == 0) {
            appendToContext(current);
        }
        current = reader.read();
        appendToContext(current);
        skipSpaces();
        _checkl('l', true);
    }
1041524
function isDirectory(filePath, callback) {
  try {
    fs.stat(filePath, function (err, data) {
      if (err) {
        callback(null, false);
      } else {
        callback(null, data.isDirectory());
      }
    });
  } catch (e) {
    callback(null, false);
  }
}
888374
private void handleDirectory(final Predicate<String> filter, final File rootDir, final List<String> discoveredFiles)
    {
        try
        {
            new DirectoryWalker<String>()
            {
                private Path startDir;

                public void walk() throws IOException
                {
                    this.startDir = rootDir.toPath();
                    this.walk(rootDir, discoveredFiles);
                }

                @Override
                protected void handleFile(File file, int depth, Collection<String> discoveredFiles) throws IOException
                {
                    String newPath = startDir.relativize(file.toPath()).toString();
                    if (filter.accept(newPath))
                        discoveredFiles.add(newPath);
                }

            }.walk();
        }
        catch (IOException ex)
        {
            LOG.log(Level.SEVERE, "Error reading Furnace addon directory", ex);
        }
    }
1105533
function get_node_from_parent_directory_data(error, parentDirectoryData) {
    if(error) {
      callback(error);
    } else {
      if(!parentDirectoryData.hasOwnProperty(name)) {
        callback(new Errors.ENOENT(null, path));
      } else {
        var nodeId = parentDirectoryData[name].id;
        context.getObject(nodeId, create_node);
      }
    }
  }
1127312
static void maybeAddFinally(Node tryNode) {
    checkState(tryNode.isTry());
    if (!NodeUtil.hasFinally(tryNode)) {
      tryNode.addChildToBack(IR.block().srcref(tryNode));
    }
  }
552481
private Node tryFoldCtorCall(Node n) {
    checkArgument(n.isNew());

    // we can remove this for GETELEM calls (anywhere else?)
    if (inForcedStringContext(n)) {
      return tryFoldInForcedStringContext(n);
    }
    return n;
  }
1161963
public static void checkValidDir(final File dir) {
        checkNotNull("dir", dir);
        if (!dir.exists()) {
            throw new IllegalArgumentException("The directory '" + dir + "' does not exist!");
        }
        if (!dir.isDirectory()) {
            throw new IllegalArgumentException("The name '" + dir + "' is not a directory!");
        }
    }
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;
			}
		}
	}