| 379 | } |
| 380 | |
| 381 | static void |
| 382 | fts_load(FTS* sp, FTSENT* p) |
| 383 | { |
| 384 | size_t len; |
| 385 | char* cp; |
| 386 | |
| 387 | /* |
| 388 | * Load the stream structure for the next traversal. Since we don't |
| 389 | * actually enter the directory until after the preorder visit, set |
| 390 | * the fts_accpath field specially so the chdir gets done to the right |
| 391 | * place and the user can access the first node. From yfts_open it's |
| 392 | * known that the path will fit. |
| 393 | */ |
| 394 | len = p->fts_pathlen = p->fts_namelen; |
| 395 | memmove((void*)sp->fts_path, (void*)p->fts_name, len + 1); |
| 396 | if ((cp = strrchr(p->fts_name, LOCSLASH_C)) != nullptr && (cp != p->fts_name || cp[1])) { |
| 397 | len = strlen(++cp); |
| 398 | memmove((void*)p->fts_name, (void*)cp, len + 1); |
| 399 | p->fts_namelen = (u_short)len; |
| 400 | } |
| 401 | p->fts_accpath = p->fts_path = sp->fts_path; |
| 402 | sp->fts_dev = p->fts_dev; |
| 403 | } |
| 404 | |
| 405 | int yfts_close(FTS* sp) |
| 406 | { |