Recursive function to put subfolders of special folders in place
961432
protected function sort_folder_specials($folder, &$list, &$specials, &$out)
    {
        foreach ($list as $key => $name) {
            if ($folder === null || strpos($name, $folder.$this->delimiter) === 0) {
                $out[] = $name;
                unset($list[$key]);

                if (!empty($specials) && ($found = array_search($name, $specials)) !== false) {
                    unset($specials[$found]);
                    $this->sort_folder_specials($name, $list, $specials, $out);
                }
            }
        }

        reset($list);
    }
108408
def ls_dir(base_dir):
    """"""
    return [
        os.path.join(dirpath.replace(base_dir, '', 1), f)
        for (dirpath, dirnames, files) in os.walk(base_dir)
        for f in files
    ]
717201
function recurseSrcDirectories (grunt, fileData, options) {
    let promises = [];

    // Ignore everything except directories and Javascript files.
    // Store function in array for recursive-readdir module.
    let ignoreCallback = [(file, stats) => !(stats.isDirectory() || path.extname(file) === '.js')];

    for (let i = 0, max = fileData.src.length; i < max; i++) {
        promises.push(readDir(fileData.src[i], ignoreCallback).then((value) => value, (err) => err));
    }

    Promise.all(promises)
        .then((values) => {
            streamMatches(grunt, fileData, options, values, values.flat());
        }, throwAsyncError);
}
406574
function _recursiveMkDir(dir) {
  if (!fs.existsSync(dir)) {
    _recursiveMkDir(path.dirname(dir));
    fs.mkdirSync(dir);
  }
}
894374
function recursiveReaddirSync(path) {
  var list = []
    , files = fs.readdirSync(path)
    , stats
    ;

  files.forEach(function (file) {
    stats = fs.lstatSync(p.join(path, file));
    if(stats.isDirectory()) {
      list = list.concat(recursiveReaddirSync(p.join(path, file)));
    } else {
      list.push(p.join(path, file));
    }
  });

  return list;
}
365215
function rmdirRecursive(root, chunks, callback) {

  var chunk = chunks.pop();
  if (!chunk) {
    return callback(null);
  }
  var pathname = path.join(root, '..'); // backtrack

  return fs.exists(root, function(exists) {

    if (exists === false) { // already done
      return rmdirRecursive(root, chunks, callback);
    }
    return fs.rmdir(root, function(err) {

      if (err) {
        return callback(err);
      }
      return rmdirRecursive(pathname, chunks, callback); // let's magic
    });
  });
}
110716
function addMaping(folder) {
	Object.defineProperties(folder, {
		// Return all enumerable properties
		_subfiles: {
			get: function () {
                return filter(folder, {type: ['file','directory']}, 'keys');
            }
		},
		// Return properties with _type === 'file'
		_files: {
			get: function () {
                return filter(folder, {type: 'file'}, 'keys');
			}
		},
		// Return properties with _type === 'directory'
		_folders: {
			get: function () {
                return filter(folder, {type: 'directory'}, 'keys');
			}
		},
        __filter: {
            value: function (opts, returnArray) {
                if(!opts.recursive) {
                    return filter(folder, opts, returnArray);
                }
                opts.recursive = false;
                if(!returnArray) {
                    return filter(folder, opts, returnArray);
                }
                return filterRecursive(folder, opts, returnArray);
            }
        },
        __clear: {
            value: function () {
                folder._subfiles.forEach(function (key) {
                    delete folder[key];
                });
            }
        },
		// Function for starting mapping from current folder with opts
		__map: {
			value: function (opts, callback) {
				if (typeof opts === 'function') {
					callback = opts;
					opts = {};
				}

				folder.__list(function (err, list) {
					if (err) {
						callback(err);
						return;
					}
					mapObjects(folder, list, function (err, map) {
						if (err) {
							callback(err);
							return;
						}
						var folders = transfer(folder, map, opts);
						var count = folders.length;

						if (!opts.recursive || count === 0) {
                            if(!opts.extend) {
                                callback(null, folder);
                                return;
                            }

                            extendComponents(folder, opts, callback);
							return;
						}

						var sent = false;
						folders.forEach(function (f) {
							f.__map(opts, function (err, fMap) {
								if (err) {
									if (!sent) {
										callback(err);
										sent = true;
									}
									return;
								}
                                if (!opts.simple) {
                                    transfer(folder, fMap, opts);
                                }
								if (--count === 0) {
                                    if(!opts.extend) {
                                        callback(null, folder);
                                        return;
                                    }
                                    extendComponents(folder, opts, callback);
								}
							});
						});
					});
				});
			}
		},
        __reMap: {
            value: function (callback) {
                folder.__clear();
                folder.__map(callback);
            }
        },
        __watchMap: {
            value: function (persistent, callback) {
                if(typeof persistent === 'function') {
                    callback = persistent;
                    persistent = false;
                }
                folder.__watchList(persistent, function (err, list) {
                    if(err) {
                        callback(err);
                        return;
                    }
                    folder.__reMap(callback);
                });
            }
        },
        __extend: {
            value: function (map) {
                return utils.extend(folder, map, true);
            }
        }
	});
}
73212
def recursive_hardlink_dirs(source_d, destination_d):
    '''
    
    '''
    func = os.link
    if os.name == 'nt':
        func = shutil.copy
    if os.path.exists(destination_d):
        os.rmdir(destination_d)
    shutil.copytree(source_d, destination_d, copy_function=func)
1092172
def makedirs(path):
    """"""
    path = Path(path)

    if not path.exists():
        path.mkdir(parents=True)
509110
def mkdir(self, children, mode=0o0755, return_node=True):
        
        result = None

        if isinstance(children, (str, unicode)):
            if os.path.isabs(children):
                raise BadValueError('Cannot mkdir an absolute path: {path}'.format(path=self._pyerarchy_path))

            rel_path = os.path.join(self._pyerarchy_path, children)
            os.makedirs(rel_path, mode)

            if return_node:
                result = Node(rel_path)
        else:
            for child in children:
                self.mkdir(child, mode, False)

        return result
587846
def add_directories(names):
    """"""
    res = list(names)
    seen = set(names)
    for name in names:
        while True:
            name = os.path.dirname(name)
            if not name or name in seen:
                break
            res.append(name)
            seen.add(name)
    return sorted(res)
422268
def add_folder(self, folder):
        
        if folder in self.folders:
            return

        self.folders.add(folder)
        
        for subfolder, junk, filenames in os.walk(folder):
            for filename in filenames:
                name, ext = os.path.splitext(filename)
                if ext in self.exts:
                    self.images.append(
                        os.path.join(subfolder, filename))
1181810
static function RecursiveUnlinkDir($dir,&$error = null,&$error_str = null){
		$error = false;
		$error_str = "";
		settype($dir,"string");
		return Files::_RecursiveUnlinkDir($dir,$error,$error_str);
	}
1300181
function moveFilesToRoot(subdir) {
  return exec(`mv ${docPath}/${subdir}/* ${docPath}`)
    .then(() => {
      exec(`rmdir ${docPath}/${subdir}`);
    })
    .catch(e => console.error(e));
}
1043477
def do_folder_create(client, args):
    """"""
    for folder_uri in args.uris:
        client.create_folder(folder_uri, recursive=True)
    return True
868395
function make_foldable(folder) {
  return function(xs) {
           return { fold: default_folder }

           function default_folder(initial, step, done) {
             done = done || identity
             folder(xs, initial, step, done) }}}
299974
function (parent) {
	var elems = fs.readdirSync( parent ),
		d = {
			files : [],
			folders : []
		};

	// get files and folders paths
	elems.forEach( function (elem) {
		var el = parent + '/' + elem;
		if (!isDir( el )) {
			d.files.push( el );
		} else if (!fs.existsSync( el + '.json')) {
			// add folder only if has no namesake json
			d.folders.push( el );
		}
	});

	return d;
}