pike.git / src / modules / _Stdio / file.c

version» Context lines:

pike.git/src/modules/_Stdio/file.c:3322: Inside #if defined(HAVE_FDOPENDIR) && defined(HAVE_OPENAT)
   struct pike_string *path = NULL;    ptrdiff_t name_max = -1;    DIR *dir = NULL;       if(FD < 0)    Pike_error("File not open.\n");       get_all_args(NULL, args, ".%S", &path);       if (path && string_has_null(path)) { -  fprintf(stderr, "NULL\n"); +     /* Filenames with NUL are not supported. */    ERRNO = errno = ENOENT;    pop_n_elems(args);    push_int(0);    return;    }       fd = FD;    dfd = -1;       while(1) {    THREADS_ALLOW_UID(); -  if (!path) { +  /* NB: The empty string is also an alias for the current directory. +  * This is a convenience eg when recursing with dirname(). +  */ +  if (!path || !path->len) {    dfd = dup(fd);    } else {    dfd = openat(fd, path->str, O_RDONLY);    }    THREADS_DISALLOW_UID();       if ((dfd == -1) && (errno == EINTR)) {    check_threads_etc();    continue;    }