Finds all paths/files which have an suid/sgid bit enabled.

    Starting with the root_path, this will recursively find all paths which
    have an suid or sgid bit set.
347919
def find_paths_with_suid_sgid(root_path):
    
    cmd = ['find', root_path, '-perm', '-4000', '-o', '-perm', '-2000',
           '-type', 'f', '!', '-path', '/proc/*', '-print']

    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, _ = p.communicate()
    return set(out.split('\n'))
446782
def root_folders
        @root_folders ||= Dir.glob("#{Dir.pwd}/*", File::FNM_DOTMATCH).collect do |f|
          File.basename(f) if File.directory?(f)
        end.reject { |dir| %w(. ..).include?(dir) }.compact!
      end
1182069
def getFilePathsWithExtensionsInDirectory(dirTree, patterns, sort=True):
    
    filePaths = []
    for root, dirs, files in os.walk(dirTree):
        for filePath in files:
            for pattern in patterns:
                if fnmatch.fnmatch(filePath, pattern):
                    fullPath = os.path.join(root, filePath)
                    filePaths.append(fullPath)
                    break
    if sort:
        filePaths.sort()
    return filePaths
670802
def _find_files(metadata):
    '''
    
    '''

    ret = {}

    for bucket, data in six.iteritems(metadata):
        if bucket not in ret:
            ret[bucket] = []

        # grab the paths from the metadata
        filePaths = [k['Key'] for k in data]
        # filter out the dirs
        ret[bucket] += [k for k in filePaths if not k.endswith('/')]

    return ret
463312
static Collection<Path> findFiles(Path dir) {
		return toPaths(dir.toFile().listFiles((FileFilter) FileFileFilter.FILE));
	}
1301198
private void scanForUnknownDirectories() {
      File[] filesInRoot = rootDirectory.listFiles();
      if (filesInRoot != null) {
         for (File maybeDirectory : filesInRoot) {
            if (maybeDirectory.isDirectory()) {
               String name = maybeDirectory.getName();
               try {
                  getDirectory(name);
               }
               catch (PersistenceException e) {
                  log.couldNotWalkDirectory(name, e);
               }
            }
         }
      }
   }
499405
def check_directory_paths(self, *args):
        
        for path in enumerate(args):
            path = path[1]
            if path is not None:
                try:
                    self.check_directory_path(path)
                except OSError as ex:
                    logger.warn(ex)
                    raise
        return args
672356
def find_root_with_flag(flag, default=nil)
      root_path = self.called_from[0]

      while root_path && ::File.directory?(root_path) && !::File.exist?("#{root_path}/#{flag}")
        parent = ::File.dirname(root_path)
        root_path = parent != root_path && parent
      end

      root = ::File.exist?("#{root_path}/#{flag}") ? root_path : default
      raise "Could not find root path for #{self}" unless root

      RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ?
      Pathname.new(root).expand_path : Pathname.new(root).realpath
    end
823065
def find(root: Union[Path, str], dirs: bool = True) -> str:
    
    if isinstance(root, str):
        root = Path(root)

    results: List[Path] = []
    for dirpath, dirnames, filenames in os.walk(root):
        names = filenames
        if dirs:
            names += dirnames
        for name in names:
            results.append(Path(dirpath) / name)
    results.sort()
    return "\n".join(str(result.relative_to(root)) for result in results)
519934
def find_all_files(self):
		
		files = self.find_files()
		subrepo_files = (
			posixpath.join(subrepo.location, filename)
			for subrepo in self.subrepos()
			for filename in subrepo.find_files()
		)
		return itertools.chain(files, subrepo_files)
410399
def list_path(root_dir):
    
    res = []
    if os.path.isdir(root_dir):
        for name in os.listdir(root_dir):
            res.append(name)
    return res
305823
private static Set<File> findAllFiles(File dir) {
        Set<File> foundFiles = new HashSet<>();
        if (dir == null) {
            return foundFiles;
        }
        recurse(dir, foundFiles);
        return foundFiles;
    }
751337
private void findAdditionalPossiblePaths(Map<String, List<String>> pathNodes,
                                             List<String> paths,
                                             String base,
                                             String baseType,
                                             int maxDepth,
                                             String logPrefix) {
        if (maxDepth == 0) {
            return;
        }

        LOG.debug("Possible:{} > {}:{}", logPrefix, baseType, base);

        if (pathNodes.containsKey(baseType)) {
            List<String> childPaths = pathNodes.get(baseType);
            if (childPaths != null) {
                for (String childPath : childPaths) {
                    final int colonPos = childPath.indexOf(':');
                    final String childType = childPath.substring(0, colonPos);
                    final String childName = childPath.substring(colonPos + 1);

                    String childBase;
                    if (base.isEmpty()) {
                        childBase = childName;
                    } else {
                        if (childName.isEmpty()) {
                            childBase = base;
                        } else {
                            childBase = base + '.' + childName;
                        }
                    }

                    String newPath = childType + ':' + childBase;
                    if (!paths.contains(newPath)) {
                        LOG.debug("Possible:{} + {}:{}", logPrefix, childType, childBase);
                        paths.add(childType + ':' + childBase);

                        findAdditionalPossiblePaths(pathNodes, paths, childBase, childType, maxDepth - 1, logPrefix + "--");
                    }
                }
            }
        }
        LOG.debug("Possible:{} < {}:{}", logPrefix, baseType, base);
    }
1029349
def filter_dirs(root, dirs, excl_paths):
    
    filtered_dirs = []
    for dirpath in dirs:
        abspath = os.path.abspath(os.path.join(root, dirpath))
        if os.path.basename(abspath) in _SKIP_DIRS:
            continue
        if abspath not in excl_paths:
            filtered_dirs.append(dirpath)
    return filtered_dirs
1204066
def _find_paths(self, current_dir, patterns):
        """"""
        pattern = patterns[0]
        patterns = patterns[1:]
        has_wildcard = is_pattern(pattern)
        using_globstar = pattern == "**"

        # This avoids os.listdir() for performance
        if has_wildcard:
            entries = [x.name for x in scandir(current_dir)]
        else:
            entries = [pattern]

        if using_globstar:
            matching_subdirs = map(lambda x: x[0], walk(current_dir))
        else:
            subdirs = [e for e in entries
                       if os.path.isdir(os.path.join(current_dir, e))]
            matching_subdirs = match_entries(subdirs, pattern)

        # For terminal globstar, add a pattern for all files in subdirs
        if using_globstar and not patterns:
            patterns = ['*']

        if patterns:  # we've still got more directories to traverse
            for subdir in matching_subdirs:
                absolute_path = os.path.join(current_dir, subdir)
                for match in self._find_paths(absolute_path, patterns):
                    yield match

        else:  # we've got the last pattern
            if not has_wildcard:
                entries = [pattern + '.wsp', pattern + '.wsp.gz']
            files = [e for e in entries
                     if os.path.isfile(os.path.join(current_dir, e))]
            matching_files = match_entries(files, pattern + '.*')

            for _basename in matching_files + matching_subdirs:
                yield os.path.join(current_dir, _basename)
1330868
def _find_file(self, path, saltenv='base'):
        '''
        
        '''
        fnd = {'path': '',
               'rel': ''}

        if salt.utils.url.is_escaped(path):
            # The path arguments are escaped
            path = salt.utils.url.unescape(path)
        for root in self.opts['pillar_roots'].get(saltenv, []):
            full = os.path.join(root, path)
            if os.path.isfile(full):
                fnd['path'] = full
                fnd['rel'] = path
                return fnd
        return fnd
31787
def find(self, path, all=False):
        '''
        
        '''
        found = os.path.join(settings.STATIC_ROOT, path)
        if all:
            return [found]
        else:
            return found