Fa tanto il figo che scrive il codice più meglio di tutti e poi:
https://github.com/g...ob/master/dir.c
/* * This handles recursive filename detection with exclude * files, index knowledge etc.. * * Copyright © Linus Torvalds, 2005-2006 * Junio Hamano, 2005-2006 */
static int read_directory_recursive(struct dir_struct *dir,
const char *base, int baselen,
int check_only,
const struct path_simplify *simplify)
{
DIR *fdir;
int contents = 0;
struct dirent *de;
struct strbuf path = STRBUF_INIT;
strbuf_add(&path, base, baselen);
fdir = opendir(path.len ? path.buf : ".");
if (!fdir)
goto out;
while ((de = readdir(fdir)) != NULL) {
switch (treat_path(dir, de, &path, baselen, simplify)) {
case path_recurse:
contents += read_directory_recursive(dir, path.buf,
path.len, 0,
simplify);
continue;
case path_ignored:
continue;
case path_handled:
break;
}
contents++;
if (check_only)
break;
dir_add_name(dir, path.buf, path.len);
}
closedir(fdir);
out:
strbuf_release(&path);
return contents;
}
fdir = opendir(path.len ? path.buf : ".");
if (!fdir)
goto out;
while ((de = readdir(fdir)) != NULL) {
goto out;
goto ![]()













