Compare two file lists for files which have been created, modified or deleted.

@param parent The parent entry
@param previous The original list of paths
@param currentPaths The current list of paths
16668
private void checkAndNotify(final FileStatusEntry parent, final FileStatusEntry[] previous, final Path[] currentPaths)
      throws IOException {

    int c = 0;
    final FileStatusEntry[] current =
        currentPaths.length > 0 ? new FileStatusEntry[currentPaths.length] : FileStatusEntry.EMPTY_ENTRIES;
    for (final FileStatusEntry previousEntry : previous) {
      while (c < currentPaths.length && comparator.compare(previousEntry.getPath(), currentPaths[c]) > 0) {
        current[c] = createPathEntry(parent, currentPaths[c]);
        doCreate(current[c]);
        c++;
      }
      if (c < currentPaths.length && comparator.compare(previousEntry.getPath(), currentPaths[c]) == 0) {
        doMatch(previousEntry, currentPaths[c]);
        checkAndNotify(previousEntry, previousEntry.getChildren(), listPaths(currentPaths[c]));
        current[c] = previousEntry;
        c++;
      } else {
        checkAndNotify(previousEntry, previousEntry.getChildren(), EMPTY_PATH_ARRAY);
        doDelete(previousEntry);
      }
    }

    for (; c < currentPaths.length; c++) {
      current[c] = createPathEntry(parent, currentPaths[c]);
      doCreate(current[c]);
    }
    parent.setChildren(current);
  }
1109346
public static List<File> pathsFiles(final String paths, final Predicate<File> predicate) {
        final List<File> files = new ArrayList<File>();
        for (final String filePathAndName : paths.split(File.pathSeparator)) {
            final File file = new File(filePathAndName);
            if (file.isDirectory()) {
                try (final Stream<Path> stream = Files.walk(file.toPath(), Integer.MAX_VALUE)) {
                    stream.map(f -> f.toFile()).filter(predicate).forEach(files::add);
                } catch (final IOException ex) {
                    throw new RuntimeException("Error walking path: " + file, ex);
                }
            } else {
                if (predicate.test(file)) {
                    files.add(file);
                }
            }
        }
        return files;
    }
925767
private void createParents(String path, List<ACL> acl)
    throws InterruptedException, KeeperException

  {
    path = PathUtils.getParentPath(adjustPath(path));
    path = PathUtils.removeTrailingSlash(path);

    List<String> paths = new ArrayList<String>();

    while(!path.equals("") && getZk().exists(path, false) == null)
    {
      paths.add(path);

      path = PathUtils.getParentPath(path);
      path = PathUtils.removeTrailingSlash(path);
    }

    Collections.reverse(paths);

    for(String p : paths)
    {
      try
      {
        getZk().create(p,
                       null,
                       acl,
                       CreateMode.PERSISTENT);
      }
      catch(KeeperException.NodeExistsException e)
      {
        // ok we continue...
        if(log.isDebugEnabled())
          log.debug("parent already exists " + p);
      }
    }
  }
876
function (prevProps, prevState) {
            var wasSelected = prevProps.entry.get("selected"),
                isSelected  = this.props.entry.get("selected");

            if (isSelected && !wasSelected) {
                // TODO: This shouldn't really know about project-files-container
                // directly. It is probably the case that our Preact tree should actually
                // start with project-files-container instead of just the interior of
                // project-files-container and then the file tree will be one self-contained
                // functional unit.
                ViewUtils.scrollElementIntoView($("#project-files-container"), $(Preact.findDOMNode(this)), true);
            } else if (!isSelected && wasSelected && this.state.clickTimer !== null) {
                this.clearTimer();
            }
        }
463099
protected boolean checkParentDirs(String path, boolean create_if_absent) throws IOException {
        String[] components=Util.components(path, File.separator);
        if(components == null)
            return false;
        if(components.length == 1) // no parent directories to create, e.g. "data.txt"
            return true;

        StringBuilder sb=new StringBuilder();
        boolean first=true;

        for(int i=0; i < components.length-1; i++) {
            String tmp=components[i];
            if(!tmp.equals(File.separator)) {
                if(first)
                    first=false;
                else
                    sb.append(File.separator);
            }
            sb.append(tmp);
            String comp=sb.toString();
            if(exists(comp)) {
                if(isFile(comp))
                    throw new IOException("cannot create " + path + " as component " + comp + " is a file");
            }
            else {
                if(create_if_absent)
                    cache.put(comp, new Metadata(0, System.currentTimeMillis(), chunk_size, Metadata.DIR), (short)-1, 0);
                else
                    return false;
            }
        }
        return true;
    }
1040232
def prevparent(self, parent, depth):
        '''
        
        '''
        pdir = os.path.dirname(self.name)
        if depth > 1:  # can't jump to parent of root node!
            for c, d in parent.traverse():
                if c.name == self.name:
                    break
                if c.name.startswith(pdir):
                    parent.curline -= 1
        else:  # otherwise jus skip to previous directory
            pdir = self.name
            # - 1 otherwise hidden parent node throws count off & our
            # self.curline doesn't change!
            line = -1
            for c, d in parent.traverse():
                if c.name == self.name:
                    break
                if os.path.isdir(c.name) and c.name in parent.children[0:]:
                    parent.curline = line
                line += 1
        return pdir
11272
protected boolean deleteDirectory(Path path, boolean cleanParent) throws IOException {
        boolean pathExists = deleteIfExistsRecursively(path);
        if(pathExists && cleanParent) {
            cleanEmptyParentDirectory(path.getParent());
            return true;
        }
        return false;
    }
606191
def changes(self):
        """"""
        deleted = []
        for path in list(self.files):
            isdir = path.endswith(os.sep)
            abspath = os.path.join(self.path, path)
            try:
                is_deleted = (
                    not os.path.exists(abspath) or  # actually deleted
                    os.path.isdir(abspath) != isdir  # changed from / to folder
                )
            except EnvironmentError:
                # file is basically inaccessible at this point so we're gonna
                # assume that it was deleted
                is_deleted = True

            if is_deleted:
                deleted.append(path)
                del self.files[path]

        changed = []
        for folder, subfolders, subfiles in os.walk(self.path):
            for path in subfolders:
                path = os.path.join(folder, path)
                path = os.path.normcase(os.path.relpath(path, self.path))
                path += os.sep
                if path not in self.files:
                    # don't really care about folder mtime
                    self.files[path] = 0
                    changed.append(path)

            for path in subfiles:
                actual_path = path = os.path.join(folder, path)
                path = os.path.normcase(os.path.relpath(path, self.path))
                try:
                    mtime = os.path.getmtime(actual_path)
                    if path not in self.files:
                        # new file; set its mtime to 0 because it will be
                        # compared in the next few lines
                        self.files[path] = 0

                    if mtime > self.files[path]:
                        # file has been changed since last check
                        self.files[path] = mtime
                        changed.append(path)
                except EnvironmentError:
                    # in 99% of the cases the file has been deleted while
                    # iterating the parent folder; if the file was previously
                    # being handled, then stop handling it; otherwise ignore
                    if path in self.files:
                        deleted.append(path)
                        del self.files[path]

        self.updated = False
        return changed, deleted
163312
private void listFolder(final StructrShellCommand parent, final Iterable<AbstractFile> folder) throws FrameworkException, IOException {

		boolean hasContents = false;

		for (final AbstractFile child : folder) {

			if (parent.isAllowed(child, Permission.read, false)) {

				hasContents = true;

				if (child instanceof Folder) {

					term.setBold(true);
					term.setTextColor(4);
					term.print(child.getName() + "  ");
					term.setTextColor(7);
					term.setBold(false);

				} else {

					term.print(child.getName() + "  ");
				}
			}
		}

		if (hasContents) {
			term.println();
		}
	}
554429
private boolean checkFileLevelRelativeToRoot(Path filePath, int depth) {
    if (filePath == null) {
      return false;
    }
    Path path = filePath;
    for (int i = 0; i < depth - 1; i++) {
      path = path.getParent();
    }
    if (!path.getName().equals(folderName)) {
      return false;
    }
    return true;
  }
672096
def parent_child_paths(path, some_path):
        
        return PathFilterUtil.is_child(path, some_path) or PathFilterUtil.is_child(some_path, path)
108124
public static void mkParentDirs(final File file) throws IOException {
        // Create parent directory structure if necessary
        File parentFile = file.getParentFile();
        if (parentFile == null) {
            // File was created with a relative path
            parentFile = file.getAbsoluteFile().getParentFile();
        }
        if (parentFile != null && !parentFile.exists()) {
            if (!parentFile.mkdirs()) {
                throw new IOException("Unable to create parent directory " +
                        "structure for file " + file.getAbsolutePath());
            }
        }
    }
801894
protected void checkNewParentsInList(CmsObject userCms, List<CmsResource> resources) throws CmsException {

        Map<String, CmsResource> resourcesByPath = new HashMap<String, CmsResource>();
        CmsObject rootCms = OpenCms.initCmsObject(m_adminCms);
        rootCms.getRequestContext().setCurrentProject(userCms.getRequestContext().getCurrentProject());
        rootCms.getRequestContext().setSiteRoot("");
        for (CmsResource resource : resources) {
            resourcesByPath.put(resource.getRootPath(), resource);
        }
        for (CmsResource resource : resources) {
            if (resource.getState().isNew()) {
                String parentPath = CmsResource.getParentFolder(resource.getRootPath());
                CmsResource parent = resourcesByPath.get(parentPath);
                if (parent == null) {
                    parent = rootCms.readResource(parentPath);
                    if (parent.getState().isNew()) {
                        throw new CmsNewParentNotInWorkflowException(
                            Messages.get().container(
                                Messages.ERR_NEW_PARENT_NOT_IN_WORKFLOW_1,
                                resource.getRootPath()));
                    }
                }
            }
        }
    }
755148
private void verifyParentDir(String src) throws FileAlreadyExistsException,
      FileNotFoundException {
    Path parent = new Path(src).getParent();
    if (parent != null) {
      INode[] pathINodes = dir.getExistingPathINodes(parent.toString());
      if (pathINodes[pathINodes.length - 1] == null) {
        throw new FileNotFoundException("Parent directory doesn't exist: "
            + parent.toString());
      } else if (!pathINodes[pathINodes.length - 1].isDirectory()) {
        throw new FileAlreadyExistsException("Parent path is not a directory: "
            + parent.toString());
      }
    }
  }
750544
protected void checkFileExists( String... existingFilePath ) {
        StringBuilder sb = null;
        for( String filePath : existingFilePath ) {
            File file = new File(filePath);
            if (!file.exists()) {
                if (sb == null) {
                    sb = new StringBuilder();
                    sb.append("The following file doesn't seem to exist: ");
                }
                sb.append("\n\t").append(file.getAbsolutePath());
            }
        }
        if (sb != null)
            throw new ModelsIllegalargumentException(sb.toString(), this.getClass().getSimpleName(), pm);
    }
601467
public static List<FileStatus> listFilesRecursively(FileSystem fs, Path path, PathFilter fileFilter,
      boolean applyFilterToDirectories)
      throws IOException {
    return listFilesRecursivelyHelper(fs, Lists.newArrayList(), fs.getFileStatus(path), fileFilter,
        applyFilterToDirectories, false);
  }
489436
public static void deleteFilesRecursively( File... files ) throws IOException {

		if( files == null )
			return;

		List<File> filesToDelete = new ArrayList<> ();
		filesToDelete.addAll( Arrays.asList( files ));
		while( ! filesToDelete.isEmpty()) {
			File currentFile = filesToDelete.remove( 0 );
			if( currentFile == null
					|| ! currentFile.exists())
				continue;

			// Non-empty directory: add sub-files and reinsert the current directory after
			File[] subFiles = currentFile.listFiles();
			if( subFiles != null && subFiles.length > 0 ) {
				filesToDelete.add( 0, currentFile );
				filesToDelete.addAll( 0, Arrays.asList( subFiles ));
			}

			// Existing file or empty directory => delete it
			else if( ! currentFile.delete())
				throw new IOException( currentFile.getAbsolutePath() + " could not be deleted." );
		}
	}