comparison lib/fts_.h @ 15529:894e5e6ae541

fts: add/use new struct member, fts_dirp We are about to use this to manage any directory with too many entries to read all of them into memory at once. To do that, we'll need to save the DIR* pointer in each affected FTSENT struct. * lib/fts_.h: Include <dirent.h>. (struct FTSENT) [fts_dirp]: New member. * lib/fts.c (closedir_and_clear): Define. Use it in place of closedir so that we are sure to clear the new fts_dirp member when done with it. (fts_alloc): Initialize the new member. (fts_lfree): Free, if needed.
author Jim Meyering <meyering@redhat.com>
date Wed, 17 Aug 2011 09:20:41 +0200
parents 04a9f678e342
children 8250f2777afc
comparison
equal deleted inserted replaced
15528:8203b056cc79 15529:894e5e6ae541
65 # endif 65 # endif
66 # endif 66 # endif
67 67
68 # include <stddef.h> 68 # include <stddef.h>
69 # include <sys/types.h> 69 # include <sys/types.h>
70 # include <dirent.h>
70 # include <sys/stat.h> 71 # include <sys/stat.h>
71 # include "i-ring.h" 72 # include "i-ring.h"
72 73
73 typedef struct { 74 typedef struct {
74 struct _ftsent *fts_cur; /* current node */ 75 struct _ftsent *fts_cur; /* current node */
189 190
190 typedef struct _ftsent { 191 typedef struct _ftsent {
191 struct _ftsent *fts_cycle; /* cycle node */ 192 struct _ftsent *fts_cycle; /* cycle node */
192 struct _ftsent *fts_parent; /* parent directory */ 193 struct _ftsent *fts_parent; /* parent directory */
193 struct _ftsent *fts_link; /* next file in directory */ 194 struct _ftsent *fts_link; /* next file in directory */
195 DIR *fts_dirp; /* Dir pointer for any directory
196 containing more entries than we
197 read at one time. */
194 long fts_number; /* local numeric value */ 198 long fts_number; /* local numeric value */
195 void *fts_pointer; /* local address value */ 199 void *fts_pointer; /* local address value */
196 char *fts_accpath; /* access file name */ 200 char *fts_accpath; /* access file name */
197 char *fts_path; /* root name; == fts_fts->fts_path */ 201 char *fts_path; /* root name; == fts_fts->fts_path */
198 int fts_errno; /* errno for this node */ 202 int fts_errno; /* errno for this node */