* Populate iter->base with the necessary information on the next iteration * entry, represented by the given name. Return 0 on success and -1 * otherwise, setting errno accordingly. */
| 162 | * otherwise, setting errno accordingly. |
| 163 | */ |
| 164 | static int prepare_next_entry_data(struct dir_iterator_int *iter, |
| 165 | const char *name) |
| 166 | { |
| 167 | int err, saved_errno; |
| 168 | |
| 169 | strbuf_addstr(&iter->base.path, name); |
| 170 | /* |
| 171 | * We have to reset these because the path strbuf might have |
| 172 | * been realloc()ed at the previous strbuf_addstr(). |
| 173 | */ |
| 174 | iter->base.relative_path = iter->base.path.buf + |
| 175 | iter->levels[0].prefix_len; |
| 176 | iter->base.basename = iter->base.path.buf + |
| 177 | iter->levels[iter->levels_nr - 1].prefix_len; |
| 178 | |
| 179 | err = lstat(iter->base.path.buf, &iter->base.st); |
| 180 | |
| 181 | saved_errno = errno; |
| 182 | if (err && errno != ENOENT) |
| 183 | warning_errno("failed to stat '%s'", iter->base.path.buf); |
| 184 | |
| 185 | errno = saved_errno; |
| 186 | return err; |
| 187 | } |
| 188 | |
| 189 | int dir_iterator_advance(struct dir_iterator *dir_iterator) |
| 190 | { |
no test coverage detected