ftw.c (b03b864ac9de9984511f4e6583b35c59b391a9c3) ftw.c (9b5f005228698aee498a88b77e24c77c4a0aa487)
1/*
2 * Copyright (c) 2003 by Joel Baker.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 64 unchanged lines hidden (view full) ---

73static int __ftw_core(const char *dir, void *func, int descr, int flags,
74 enum __ftw_modes mode) {
75 FTS *hierarchy;
76 FTSENT *entry;
77 int fts_options;
78 const char *paths[2];
79 int ftw_flag, func_ret;
80 struct FTW ftw_st;
1/*
2 * Copyright (c) 2003 by Joel Baker.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 64 unchanged lines hidden (view full) ---

73static int __ftw_core(const char *dir, void *func, int descr, int flags,
74 enum __ftw_modes mode) {
75 FTS *hierarchy;
76 FTSENT *entry;
77 int fts_options;
78 const char *paths[2];
79 int ftw_flag, func_ret;
80 struct FTW ftw_st;
81 int skip_entry;
82 __ftw_func_t ftw_func;
83 __nftw_func_t nftw_func;
84 int saved_errno;
85
86 errno = 0;
87
88 /* We need at least one descriptor to call fts */
89

--- 25 unchanged lines hidden (view full) ---

115 } else {
116 return -1;
117 }
118 }
119
120 /* The main loop. Is it not nifty? Worship the loop. */
121
122 while ((entry = fts_read(hierarchy))) {
81 __ftw_func_t ftw_func;
82 __nftw_func_t nftw_func;
83 int saved_errno;
84
85 errno = 0;
86
87 /* We need at least one descriptor to call fts */
88

--- 25 unchanged lines hidden (view full) ---

114 } else {
115 return -1;
116 }
117 }
118
119 /* The main loop. Is it not nifty? Worship the loop. */
120
121 while ((entry = fts_read(hierarchy))) {
123 skip_entry = 0;
124
125 switch (entry->fts_info) {
126
127 case FTS_D:
128 if ((MODE_NFTW != mode) || !(flags & FTW_DEPTH)) {
129 ftw_flag = FTW_D;
122 switch (entry->fts_info) {
123
124 case FTS_D:
125 if ((MODE_NFTW != mode) || !(flags & FTW_DEPTH)) {
126 ftw_flag = FTW_D;
130 } else {
131 skip_entry = 1;
132 }
133 break;
134
135 case FTS_DNR:
136 ftw_flag = FTW_DNR;
137 break;
138
139 case FTS_F:

--- 16 unchanged lines hidden (view full) ---

156 } else {
157 ftw_flag = FTW_SL;
158 }
159 break;
160
161 case FTS_DP:
162 if ((MODE_NFTW == mode) && (flags & FTW_DEPTH)) {
163 ftw_flag = FTW_D;
127 }
128 break;
129
130 case FTS_DNR:
131 ftw_flag = FTW_DNR;
132 break;
133
134 case FTS_F:

--- 16 unchanged lines hidden (view full) ---

151 } else {
152 ftw_flag = FTW_SL;
153 }
154 break;
155
156 case FTS_DP:
157 if ((MODE_NFTW == mode) && (flags & FTW_DEPTH)) {
158 ftw_flag = FTW_D;
164 } else {
165 skip_entry = 1;
166 }
167 break;
168
169 default:
170 /* I'm not sure this is right, but we don't have a valid FTW
171 * type to call with, so cowardice seems the better part of
172 * guessing.
173 */
159 }
160 break;
161
162 default:
163 /* I'm not sure this is right, but we don't have a valid FTW
164 * type to call with, so cowardice seems the better part of
165 * guessing.
166 */
174
175 skip_entry = 1;
167 break;
176 }
177
178 if (MODE_FTW == mode) {
179 ftw_func = (__ftw_func_t) func;
180 func_ret = (*ftw_func)
181 (entry->fts_path, entry->fts_statp, ftw_flag);
182 } else if (MODE_NFTW == mode) {
183 ftw_st.base = (entry->fts_pathlen - entry->fts_namelen);

--- 25 unchanged lines hidden ---
168 }
169
170 if (MODE_FTW == mode) {
171 ftw_func = (__ftw_func_t) func;
172 func_ret = (*ftw_func)
173 (entry->fts_path, entry->fts_statp, ftw_flag);
174 } else if (MODE_NFTW == mode) {
175 ftw_st.base = (entry->fts_pathlen - entry->fts_namelen);

--- 25 unchanged lines hidden ---