Browse Source Download (without any required ccan dependencies)
tal/path
routines to manipulate paths
Rusty Russell <rusty@rustcorp.com.au>
This code helps manage paths.
// Program to print out full path names, recursively.
#include <ccan/tal/path/path.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <ccan/err/err.h>
static void dump(const char *dir)
{
struct dirent *di;
DIR *d = opendir(dir);
if (!d) {
warn("Failed to open %s", dir);
return;
}
printf("%s\n", dir);
while ((di = readdir(d)) != NULL) {
char *path;
if (streq(di->d_name, ".") || streq(di->d_name, ".."))
continue;
path = path_join(NULL, dir, di->d_name);
if (path_is_dir(path))
dump(path);
tal_free(path);
}
closedir(d);
}
int main(void)
{
dump(path_cwd(NULL));
return 0;
}
BSD-MIT