| * 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 |
| int iterate_on_dir (const char * dir_name, |
| int (*func) (const char *, struct dirent *, void *), |
| max_len = PATH_MAX + sizeof(struct dirent); |
| de = (struct dirent *)xmalloc(max_len+1); |
| memset(de, 0, max_len+1); |
| dir = opendir (dir_name); |
| while ((dep = readdir (dir))) { |
| len = sizeof(struct dirent); |
| (*func) (dir_name, de, private); |