[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

proposal to add apr_check_dir_empty() to APR

From: Karl Fogel <kfogel_at_newton.ch.collab.net>
Date: 2002-07-02 21:48:25 CEST

Currently, apr_check_dir_empty() is living in the Subversion source
tree. The implementation looks portable, though; is there any reason
not to move this into APR?

   apr_status_t
   apr_check_dir_empty (const char *path,
                        apr_pool_t *pool)
   {
     apr_status_t apr_err, retval;
     apr_dir_t *dir;
     apr_finfo_t finfo;
     
     apr_err = apr_dir_open (&dir, path, pool);
     if (apr_err)
       return apr_err;
         
     /* All systems return "." and ".." as the first two files, so read
        past them unconditionally. */
     apr_err = apr_dir_read (&finfo, APR_FINFO_NAME, dir);
     if (apr_err) return apr_err;
     apr_err = apr_dir_read (&finfo, APR_FINFO_NAME, dir);
     if (apr_err) return apr_err;
   
     /* Now, there should be nothing left. If there is something left,
        return EGENERAL. */
     apr_err = apr_dir_read (&finfo, APR_FINFO_NAME, dir);
     if (APR_STATUS_IS_ENOENT (apr_err))
       retval = APR_SUCCESS;
     else if (! apr_err)
       retval = APR_EGENERAL;
     else
       retval = apr_err;
   
     apr_err = apr_dir_close (dir);
     if (apr_err)
       return apr_err;
   
     return retval;
   }

Thoughts?,
-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Jul 2 21:57:47 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.