check if file is a child of given directory

@param file file to search
@param dir directory to search
@return is inside or not
519918
public static boolean isChildOf(Resource file, Resource dir) {
	while (file != null) {
	    if (file.equals(dir)) return true;
	    file = file.getParentResource();
	}
	return false;
    }
1301840
public boolean filterDirectory(File file)
    {
        boolean bProcessFile = super.filterDirectory(file);
        if (bProcessFile == false)
            return bProcessFile;
        String strName = file.getName();
        for (String strMonth : m_rgstrMonths)
        {
            if (strName.equalsIgnoreCase(strMonth))
                return false;
        }
        if (Utility.isNumeric(strName))
        {
            int iYear = Integer.parseInt(strName);
            if ((iYear > 1990) && (iYear < 2020))
                return false;
        }
        return bProcessFile;
    }
677663
public final synchronized void findFiles(File directory, FileFilter filter, Collection<? super File> fileOut) {
		if (directory != null && filter != null) {
			File candidate;
			final List<File> candidates = new ArrayList<>();

			final String relativePath = removePathPrefix(getBaseDirectory(), directory);

			getLog().debug("Retreiving " //$NON-NLS-1$
					+ filter.toString() + " files from " //$NON-NLS-1$
					+ relativePath);

			candidates.add(directory);
			int nbFiles = 0;

			while (!candidates.isEmpty()) {
				candidate = candidates.remove(0);
				if (candidate.isDirectory()) {
					final File[] children = candidate.listFiles(filter);
					if (children != null) {
						for (final File child : children) {
							if (child != null && child.isDirectory()) {
								candidates.add(child);
							} else {
								fileOut.add(child);
								++nbFiles;
							}
						}
					}
				}
			}

			getLog().debug("Found " //$NON-NLS-1$
					+ nbFiles + " file(s)"); //$NON-NLS-1$
		}
	}
1208899
@Override
  public boolean isDirectory(final Path f) throws IOException {
    if (stocatorPath.isTemporaryPath(f)) {
      return false;
    }
    final Path path = storageClient.qualify(f);
    try {
      FileStatus fileStatus = getFileStatus(path);
      LOG.debug("is directory: {} : {}", path.toString(), fileStatus.isDirectory());
      return fileStatus.isDirectory();
    } catch (FileNotFoundException e) {
      return false;
    }
  }
565446
public static boolean isDescendant(File forParent, File potentialChild) throws IOException {
        Path child = fileToPath(potentialChild.getAbsoluteFile()).normalize();
        Path parent = fileToPath(forParent.getAbsoluteFile()).normalize();
        return child.startsWith(parent);
    }
197195
public static String getPathToChild(Resource file, Resource dir) {
	if (dir == null || !file.getResourceProvider().getScheme().equals(dir.getResourceProvider().getScheme())) return null;
	boolean isFile = file.isFile();
	String str = "/";
	while (file != null) {
	    if (file.equals(dir)) {
		if (isFile) return str.substring(0, str.length() - 1);
		return str;
	    }
	    str = "/" + file.getName() + str;
	    file = file.getParentResource();
	}
	return null;
    }
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;
    }
785152
private static String checkFolder(String directory) {
        File dir = new File(directory);
        if (dir.isFile()) {
            directory = dir.getParent();
        }
        createFolder(directory);
        return directory;
    }
237992
public boolean isDirectory() {
        if (this.file != null) {
            return this.file.isDirectory();
        }

        if (this.header != null) {
            if (this.header.linkFlag == TarHeader.LF_DIR) {
                return true;
            }

            if (this.header.name.toString().endsWith("/")) {
                return true;
            }
        }

        return false;
    }
1347914
private static boolean isSavedInDir(ScriptWrapper scriptWrapper, File directory) {
		File file = scriptWrapper.getFile();
		if (file == null) {
			return false;
		}
		return file.getParentFile().equals(directory);
	}
87495
public static boolean isUnderDirectory(File child, File parent) {
        if (child == null || parent == null)
            return false;

        URI childUri = child.toURI();
        URI relativeUri = parent.toURI().relativize(childUri);
        return relativeUri.equals(childUri) ? false : true;

    }
727360
public static List<File> getAllFilesFromDir(final File dir)
	{
		final List<File> foundedFileList = new ArrayList<>();
		final File[] children = dir.getAbsoluteFile().listFiles();
		if (children == null || children.length < 1)
		{
			return foundedFileList;
		}
		for (final File child : children)
		{
			// if the entry is not a directory
			if (!child.isDirectory())
			{
				// then
				// entry is a file
				foundedFileList.add(child.getAbsoluteFile());
			}
		}
		return foundedFileList;
	}
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());
            }
        }
    }
642183
public static boolean deleteRecursive(File file) {
		
		if(!file.exists()) {
			return false;
		}
		
		if(file.isDirectory()) {
			for(File child: file.listFiles()) {
				deleteRecursive(child);
			}
		}
		return file.delete();
	}
1169588
private boolean checkFilePath(String file, int depth) {
    // The file is either a node file or an edge file and needs to be stored at either:
    // flowGraphDir/nodeName/nodeName.properties (if it is a node file), or
    // flowGraphDir/nodeName/nodeName/edgeName.properties (if it is an edge file)

    Path filePath = new Path(file);
    String fileExtension = Files.getFileExtension(filePath.getName());
    if (filePath.depth() != depth || !checkFileLevelRelativeToRoot(filePath, depth)
        || !(this.javaPropsExtensions.contains(fileExtension))) {
      log.warn("Changed file does not conform to directory structure and file name format, skipping: "
          + filePath);
      return false;
    }
    return true;
  }
1221189
public static void directoryCheck(String dir) throws IOException {
		final File file = new File(dir);

		if (!file.exists()) {
			FileUtils.forceMkdir(file);
		}
	}
357924
public static final Set<File> findFileByDirAndSubBySuffix(File dir,String ...suffix)
	{
		return findFileByDirAndSub(dir,new FileFilter() {
			@Override
			public boolean accept(File pathname) 
				{
					if(pathname.isDirectory())
					{
						return true;
					}
					if(pathname.isFile())
					{
						for(String s:suffix)
						{
							if(pathname.getName().endsWith(s))
							{
								return true;
							}
						}
					}
					return false;
				}
			});
	}