apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karl Fogel <kfo...@newton.ch.collab.net>
Subject Re: proposal to add apr_check_dir_empty() to APR
Date Tue, 02 Jul 2002 20:36:04 GMT
"Ryan Bloom" <rbb@covalent.net> writes:
> The docs may say that, but the code doesn't do anything about "." and
> "..".  I just double-checked unix/dir.c.   :-(  I actually remember
> looking at this years ago when I wrote the original code, and thinking
> through the "." and ".." problem, which is why I said that APR will
> return those two values first, but I don't think I ever actually coded
> it, and I'm not sure how it would be done.

Heh!  Pardon me while I feel smug :-)...

I also felt a bit suspicious about that promise, and therefore wrote
this code in Subversion a while back:

  for (err = svn_io_dir_read (&finfo, flags, dir, pool);
       err == SVN_NO_ERROR;
       svn_pool_clear (subpool),
         err = svn_io_dir_read (&finfo, flags, dir, pool))
      const char *this_path, *this_edit_path;

      if (finfo.filetype == APR_DIR)
          /* Skip entries for this dir and its parent.  
             (APR promises that they'll come first, so technically
             this guard could be moved outside the loop.  But somehow
             that feels iffy. */
          if (finfo.name[0] == '.'
              && (finfo.name[1] == '\0'
                  || (finfo.name[1] == '.' && finfo.name[2] == '\0')))




Anyway, will do something similar in apr_dir_check_empty().


View raw message