Collect all of the directories listed within enclosed path tags. Order of
the path elements is preserved. Duplicates are included where first
specified.

@param p
Path containing directories to include in compilation
507743
private void addPaths(Path p) {

        for (String d : p.list()) {
            File dir = new File(d);
            if (dir.exists() && dir.isDirectory()) {
                if (!includeDirectories.contains(dir))
                    includeDirectories.add(dir);
            }
        }
    }
918509
public CmsPathTree<P, V> findNode(List<P> path) {

        List<P> pathToConsume = Lists.newLinkedList(path);
        CmsPathTree<P, V> descendant = findNodeInternal(pathToConsume);
        if (!pathToConsume.isEmpty()) {
            return null;
        } else {
            return descendant;
        }
    }
518374
public static List<String> getResourcesList(String path) {
    Set<String> resList = new HashSet<>(); // subdirectories can cause duplicate entries
    try {
      // Java doesn't allow simple exploration of resources as directories
      // when the resources are inside a jar file. This searches the contents
      // of the jar to get the list
      URL classUrl = JarHash.class.getResource("/water/H2O.class");
      if (classUrl != null && classUrl.getProtocol().equals("jar")) {
        // extract jarPath from classUrl string
        String jarPath = classUrl.getPath().substring(5, classUrl.getPath().indexOf("!"));
        JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
        Enumeration<JarEntry> files = jar.entries();
        // look for all entries within the supplied resource path
        while (files.hasMoreElements()) {
          String fName = files.nextElement().getName();
          if (fName.startsWith(path + "/")) {
            String resourceName = fName.substring((path + "/").length());
            int checkSubdir = resourceName.indexOf("/");
            if (checkSubdir >= 0) // subdir, trim to subdir name
              resourceName = resourceName.substring(0, checkSubdir);
            if (resourceName.length() > 0) resList.add(resourceName);
          }
        }
      } else { // not a jar, retrieve resource from file system
        String resourceName;
        BufferedReader resources = new BufferedReader(new InputStreamReader(JarHash.class.getResourceAsStream("/gaid")));
        if (resources != null) {
          while ((resourceName = resources.readLine()) != null)
            if (resourceName.length() > 0)
              resList.add(resourceName);
        }
      }
    }catch(Exception ignore){
      Log.debug("Failed in reading gaid resources.");
    }
    return new ArrayList<>(resList);
  }
1187217
public void setExludedDirMapperDirs(Set<String> exludedDirMapperDirs) {
		if (null != exludedDirMapperDirs)
			this.excludedDirMapperDirs = PathNormalizer.normalizePaths(exludedDirMapperDirs);
	}
559009
@Override
    public Enumeration<String> getEntryPaths(String path, boolean recurse) {
        path = preSlashify(path);
        Iterator<Entry> entries;
        if (path.equals("/")) {
            // asking for entries of the root container
            entries = container.iterator();
        } else {
            Entry entry = container.getEntry(path);
            Container entryContainer = entry == null ? null : getContainer(entry);
            // Check if the entry is a container; 
            // if so only iterate over its entries if the container is not a root
            entries = entryContainer == null || entryContainer.isRoot() ? null : entryContainer.iterator();
            path = postSlashify(path, null);
        }
        return entries == null ? null : new ContainerEnumeration(path, entries, recurse);
    }
542280
private void collectFiles(final File folder, final List<File> found) {
		File[] files = folder.listFiles();
		if (files != null) {
			for (File file : files) {
				if (file.isDirectory()) {
					collectFiles(file, found);
				} else if (file.isFile() && file.getPath().endsWith(suffix)) {
					int index = 0;

					for (String text : plainTexts) {
						index = file.getPath().indexOf(text, index);
						if (index == -1) {
							break;
						} else {
							index += text.length();
						}
					}

					if (index >= 0) {
						found.add(file);
					}
				}
			}
		}
	}
1040037
public void mkdirs(URI path) throws IOException {
    logger.atFine().log("mkdirs(%s)", path);
    Preconditions.checkNotNull(path);

    if (path.equals(GCS_ROOT)) {
      // GCS_ROOT directory always exists, no need to go through the rest of the method.
      return;
    }

    StorageResourceId resourceId = pathCodec.validatePathAndGetId(path, true);
    resourceId = FileInfo.convertToDirectoryPath(resourceId);

    // Create a list of all intermediate paths.
    // For example,
    // gs://foo/bar/zoo/ => (gs://foo/, gs://foo/bar/, gs://foo/bar/zoo/)
    //
    // We also need to find out if any of the subdir path item exists as a file
    // therefore, also create a list of file equivalent of each subdir path.
    // For example,
    // gs://foo/bar/zoo/ => (gs://foo/bar, gs://foo/bar/zoo)
    List<String> subdirs = getSubDirs(resourceId.getObjectName());
    List<StorageResourceId> itemIds = new ArrayList<>(subdirs.size() * 2 + 1);
    for (String subdir : subdirs) {
      itemIds.add(new StorageResourceId(resourceId.getBucketName(), subdir));
      if (!Strings.isNullOrEmpty(subdir)) {
        itemIds.add(
            new StorageResourceId(resourceId.getBucketName(), FileInfo.convertToFilePath(subdir)));
      }
    }
    // Add the bucket portion.
    itemIds.add(new StorageResourceId(resourceId.getBucketName()));
    logger.atFine().log("mkdirs: items: %s", itemIds);

    List<GoogleCloudStorageItemInfo> itemInfos = gcs.getItemInfos(itemIds);

    // Each intermediate path must satisfy one of the following conditions:
    // -- it does not exist or
    // -- if it exists, it is a directory
    //
    // If any of the intermediate paths violates these requirements then
    // bail out early so that we do not end up with partial set of
    // created sub-directories. It is possible that the status of intermediate
    // paths can change after we make this check therefore this is a
    // good faith effort and not a guarantee.
    GoogleCloudStorageItemInfo bucketInfo = null;
    List<StorageResourceId> subdirsToCreate = new ArrayList<>(subdirs.size());
    for (GoogleCloudStorageItemInfo info : itemInfos) {
      if (info.isBucket()) {
        checkState(bucketInfo == null, "bucketInfo should be null");
        bucketInfo = info;
      } else if (info.getResourceId().isDirectory() && !info.exists()) {
        subdirsToCreate.add(info.getResourceId());
      } else if (!info.getResourceId().isDirectory() && info.exists()) {
        throw new FileAlreadyExistsException(
            "Cannot create directories because of existing file: " + info.getResourceId());
      }
    }

    if (!checkNotNull(bucketInfo, "bucketInfo should not be null").exists()) {
      gcs.create(bucketInfo.getBucketName());
    }
    gcs.createEmptyObjects(subdirsToCreate);

    // Update parent directories, but not the ones we just created because we just created them.
    List<URI> createdDirectories =
        subdirsToCreate.stream()
            .map(s -> pathCodec.getPath(s.getBucketName(), s.getObjectName(), false))
            .collect(toImmutableList());
    tryUpdateTimestampsForParentDirectories(createdDirectories, createdDirectories);
  }
157589
@Override
    public T addAsDirectories(String... paths) throws IllegalArgumentException {
        this.getArchive().addAsDirectories(paths);
        return covarientReturn();
    }
29253
private static List<Path> file_listing_(Path dir) throws IOException {
        try (Stream<Path> files = Files.list(dir)) {
            return files.collect(Collectors.toList());
        }
    }
604287
private void sortPathByDepth(Path[] paths) {
    Arrays.sort(paths, new Comparator<Path> (){
      @Override
      public int compare(Path o1, Path o2) {
        return ((Integer)o1.depth()).compareTo(o2.depth());
      }});
  }
1229402
private List<CmsResource> getContents(String folderPath, String type) throws CmsException {

        CmsPathMap<CmsResource> pathMap = getPathMapForType(type);
        return pathMap.getChildValues(folderPath);
    }
335984
private void primGetAllDirectoriesBelow(File dir, Set allDirectories) {
        File[] files = dir.listFiles(fileFilter);
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory()) {
                primGetAllDirectoriesBelow(files[i], allDirectories);
                allDirectories.add(files[i]);
            }
        }
    }
1292440
public static ArrayList<File> getFilesInDirectoryTree(String path, FileFilterRuleSet includeRuleSet) {
		File file = new File(path);
		return getContentsInDirectoryTree(file, includeRuleSet, true, false);
	}
299440
public static String getDirectoryname(final String pPath, final char pSeparator) {
        int index = pPath.lastIndexOf(pSeparator);

        if (index < 0) {
            return "";  // Assume only filename
        }
        return pPath.substring(0, index);
    }
605663
public List<V> getDescendantValues(List<P> path) {

        CmsPathTree<P, V> node = findNode(path);
        List<V> result = Lists.newArrayList();
        if (node != null) {
            node.collectEntries(result);
        }
        return result;
    }
377436
public static List<Path> getSubFilePathList(Path startDirectoryPath,
			int maxDepth) {
		return getSubPathList(startDirectoryPath, maxDepth, RegularFileFilter);
	}
722946
def collect_files(path, extension):
    """"""

    # We should only call this on an actual directory; callers should do the
    # validation.
    assert os.path.isdir(path)
    out = []
    # glob would be faster (see PEP471) but python glob doesn't do **/*
    for root, _, files in os.walk(path):
        out += [os.path.join(root, f) for f in files if f.endswith(extension)]
    return out