recurse on other directories
358827
def process_directory(dirname, level=1)
      begin
        entries = Dir.entries(dirname).sort
      rescue Errno::EACCES => e
        $stderr.puts e
        @visitor.cannot_enter_node(dirname, e)
        return
      rescue Errno::EPERM => e
        $stderr.puts e
        @visitor.cannot_enter_node(dirname, e)
        return
      rescue Errno::ENOENT => e
        $stderr.puts e
        @visitor.cannot_enter_node(dirname, e)
        return
      end


      @visitor.enter_node(dirname)
      entries.each do |basename|
        begin
          next if basename == '.' or basename == '..' # ignore always "." and ".."
          pathname = File.join(dirname, basename)

          if File.directory?(pathname)
            if not ignore_dir?(basename) and (@max_level.nil? or @max_level > level)
              process_directory(pathname, level+1)
            end
          else
            if !!@visit_file && match?(basename) && !ignore_file?(basename)
              @visitor.visit_leaf(pathname)
            end
          end
        rescue Errno::EACCES => e
          $stderr.puts e
        rescue Errno::EPERM => e
          $stderr.puts e
        rescue Errno::ENOENT => e
          $stderr.puts e
        end
      end

      @visitor.exit_node(dirname)
    end
779902
def files_in_dir(path, extension):
    """"""
    ends = '.{0}'.format(extension)
    return (f for f in os.listdir(path) if f.endswith(ends))
813356
def dir_attribs(location, mode=None, owner=None,
                group=None, recursive=False, use_sudo=False):
    
    recursive = recursive and "-R " or ""
    if mode:
        if use_sudo:
            sudo('chmod %s %s %s' % (recursive, mode,  location))
        else:
            run('chmod %s %s %s' % (recursive, mode,  location))
    if owner:
        if use_sudo:
            sudo('chown %s %s %s' % (recursive, owner, location))
        else:
            run('chown %s %s %s' % (recursive, owner, location))
    if group:
        if use_sudo:
            sudo('chgrp %s %s %s' % (recursive, group, location))
        else:
            run('chgrp %s %s %s' % (recursive, group, location))
331075
def listdir(self, path):
        '''
        
        '''
        for f in os.listdir(path):
            if not f.startswith('.'):
                yield f
671616
def chdir(new_dir):
    
    cur_dir = os.getcwd()
    _mkdir(new_dir)
    os.chdir(new_dir)
    try:
        yield
    finally:
        os.chdir(cur_dir)
208690
function mkdirRecursive(dir) {
  var parts = path.normalize(dir).split(path.sep);
  dir = '';
  for (var i = 0; i < parts.length; i++) {
    dir += parts[i] + path.sep;
    if (!existsSync(dir)) {
      fs.mkdirSync(dir, 0x1FD); // 0775 permissions
    }
  }
}
185208
def recursive_dirname(f):
  
  prev = None
  while f != prev:
    yield f
    prev = f
    f = os.path.dirname(f)
  yield ''
112509
def _listdir(pth, extensions):
    """"""
    try:
        return [fname for fname in os.listdir(pth)
                if os.path.splitext(fname)[1] in extensions]
    except OSError:  # pragma: nocover
        pass
305823
private static Set<File> findAllFiles(File dir) {
        Set<File> foundFiles = new HashSet<>();
        if (dir == null) {
            return foundFiles;
        }
        recurse(dir, foundFiles);
        return foundFiles;
    }
406574
function _recursiveMkDir(dir) {
  if (!fs.existsSync(dir)) {
    _recursiveMkDir(path.dirname(dir));
    fs.mkdirSync(dir);
  }
}
273576
def get_files(dir_name):
    """"""
    return [(os.path.join('.', d), [os.path.join(d, f) for f in files]) for d, _, files in os.walk(dir_name)]
829106
function mkdirIf(dir, parent) {
	var path = parent ? parent : ".";
	if (getDirectories(path).indexOf(dir) == -1) fs.mkdirSync(path + "/" + dir);
}
1283540
def find_directories(root,fullpath=True):
    '''
    
    '''
    directories = []
    for item in os.listdir(root):
        # Don't include hidden directories
        if not re.match("^[.]",item):
            if os.path.isdir(os.path.join(root, item)):
                if fullpath:
                    directories.append(os.path.abspath(os.path.join(root, item)))
                else:
                    directories.append(item)
    return directories
749850
def traverse_directory(dir_path, yield_dir=False):
    
    if not os.path.isdir(dir_path):
        return

    for item in os.listdir(dir_path):
        new_path = os.path.join(dir_path, item)
        if os.path.isdir(new_path):
            if yield_dir:
                yield new_path + os.path.sep
            yield from traverse_directory(new_path, yield_dir)
        else:
            yield new_path
848218
def mk_dir(self) :
        """"""
        if not os.path.exists(self.abs) :
            os.makedirs(self.abs)
190095
def ls_recurse(path, include_hidden=False):
    
    lst = []
    for file in os.listdir(path):
        hidden_file = FileSystem(file).is_hidden()
        if (hidden_file and include_hidden) or (not hidden_file):
            lst.append(os.path.join(path, file))
            if is_folder(os.path.join(path, file)):
                lst += ls_recurse(
                    os.path.join(path, file),
                    include_hidden=include_hidden
                )  # get list of files in directory
    return list(set(lst))
173055
def directory_files(path):
    """"""

    for entry in os.scandir(path):
        if not entry.name.startswith('.') and entry.is_file():
            yield entry.name