VirtualBox

Changeset 2990 in kBuild


Ignore:
Timestamp:
Nov 1, 2016 9:55:39 PM (8 years ago)
Author:
bird
Message:

fts-nt: Ported fts_children.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt/fts-nt.c

    r2989 r2990  
    176176                       the API user code happy.  1. Lone drive letters get a dot
    177177                       appended so it won't matter if a slash is appended afterwards.
    178                            2. DOS slashes are converted to UNIX ones. */
     178                       2. DOS slashes are converted to UNIX ones. */
    179179                char *slash;
    180180                len = strlen(*argv);
     
    261261        len = p->fts_pathlen = p->fts_namelen;
    262262        memmove(sp->fts_path, p->fts_name, len + 1);
    263 /** @todo check for ':' and '\\'? */
    264263        if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) {
    265264                len = strlen(++cp);
     
    510509}
    511510
    512 #if 0
    513511FTSENT * FTSCALL
    514512fts_children(FTS *sp, int instr)
    515513{
    516514        FTSENT *p;
    517         int fd, rc, serrno;
    518515
    519516        if (instr != 0 && instr != FTS_NAMEONLY) {
     
    548545
    549546        /* Free up any previous child list. */
    550         if (sp->fts_child != NULL)
     547        if (sp->fts_child != NULL) {
    551548                fts_lfree(sp->fts_child);
    552 
     549                sp->fts_child = NULL; /* (bird - double free for _open(".") failure in original) */
     550        }
     551
     552        /* NT: Some BSD utility sets FTS_NAMEONLY? We don't really need this
     553               optimization, but since it only hurts that utility, it can stay.  */
    553554        if (instr == FTS_NAMEONLY) {
     555                assert(0); /* don't specify FTS_NAMEONLY on NT. */
    554556                SET(FTS_NAMEONLY);
    555557                instr = BNAMES;
     
    557559                instr = BCHILD;
    558560
    559         /*
    560          * If using chdir on a relative path and called BEFORE fts_read does
    561          * its chdir to the root of a traversal, we can lose -- we need to
    562          * chdir into the subdirectory, and we don't know where the current
    563          * directory is, so we can't get back so that the upcoming chdir by
    564          * fts_read will work.
    565          */
    566         if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' ||
    567             ISSET(FTS_NOCHDIR))
    568                 return (sp->fts_child = fts_build(sp, instr));
    569 
    570         if ((fd = _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0)
    571                 return (NULL);
    572         sp->fts_child = fts_build(sp, instr);
    573         serrno = (sp->fts_child == NULL) ? errno : 0;
    574         rc = fchdir(fd);
    575         if (rc < 0 && serrno == 0)
    576                 serrno = errno;
    577         (void)_close(fd);
    578         errno = serrno;
    579         if (rc < 0)
    580                 return (NULL);
    581         return (sp->fts_child);
    582 }
    583 #endif /* PORTME */
     561        return (sp->fts_child = fts_build(sp, instr));
     562}
    584563
    585564#ifndef fts_get_clientptr
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette