diff options
author | Theodore Ts'o <tytso@mit.edu> | 1997-04-26 13:21:57 +0000 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 1997-04-26 13:21:57 +0000 |
commit | 3839e65723771b85975f4263102dd3ceec4523c0 (patch) | |
tree | 02fde6f8259837e842e12bdc97bb9f92e4155b44 /lib/e2p/iod.c | |
download | e2fsprogs-3839e65723771b85975f4263102dd3ceec4523c0.tar.gz |
Many files:
Checkin of e2fsprogs 0.5b
Diffstat (limited to 'lib/e2p/iod.c')
-rw-r--r-- | lib/e2p/iod.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/e2p/iod.c b/lib/e2p/iod.c new file mode 100644 index 00000000..52c16a13 --- /dev/null +++ b/lib/e2p/iod.c @@ -0,0 +1,42 @@ +/* + * iod.c - Iterate a function on each entry of a directory + * + * Copyright (C) 1993, 1994 Remy Card <card@masi.ibp.fr> + * Laboratoire MASI, Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) + * + * This file can be redistributed under the terms of the GNU Library General + * Public License + */ + +/* + * History: + * 93/10/30 - Creation + */ + +#include <dirent.h> + +#include "e2p.h" + +int iterate_on_dir (const char * dir_name, + int (*func) (const char *, struct dirent *, void *), + void * private) +{ + DIR * dir; + struct dirent de; + struct dirent *dep; + + dir = opendir (dir_name); + if (dir == NULL) + return -1; + while ((dep = readdir (dir))) + { + de.d_ino = dep->d_ino; + de.d_off = dep->d_off; + de.d_reclen = dep->d_reclen; + strcpy (de.d_name, dep->d_name); + (*func) (dir_name, &de, private); + } + closedir (dir); + return 0; +} |