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

Re: dot, dot-dot and apr_dir_read

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2004-02-17 18:00:59 CET

Ben Collins-Sussman <sussman@collab.net> writes:

> Yeah, can someone submit a real patch for 'svnadmin copy'? I'd love to
> get this into 1.0.1.

Here's my work in progress:

* subversion/libsvn_subr/io.c (svn_io_dir_walk): Make the callback for
  a directory before the callbacks for any items it contains.

Index: subversion/libsvn_subr/io.c
===================================================================
--- subversion/libsvn_subr/io.c (revision 8659)
+++ subversion/libsvn_subr/io.c (working copy)
@@ -1883,9 +1883,13 @@
   apr_dir_t *handle;
   apr_pool_t *subpool;
   const char *dirname_apr;
+ apr_finfo_t finfo;
 
   wanted |= APR_FINFO_TYPE | APR_FINFO_NAME;
 
+ SVN_ERR (svn_io_stat (&finfo, dirname, wanted & ~APR_FINFO_NAME, pool));
+ SVN_ERR ((*walk_func) (walk_baton, dirname, &finfo, pool));
+
   SVN_ERR (svn_path_cstring_from_utf8 (&dirname_apr, dirname, pool));
 
   apr_err = apr_dir_open (&handle, dirname_apr, pool);
@@ -1897,7 +1901,6 @@
 
   for ( ; ; svn_pool_clear (subpool))
     {
- apr_finfo_t finfo;
       const char *name_utf8;
       const char *full_path;
 
@@ -1912,28 +1915,12 @@
 
       if (finfo.filetype == APR_DIR)
         {
- if (finfo.name[0] == '.')
- {
- if (finfo.name[1] == '\0')
- {
- /* current directory. pass the full directory name to
- the callback */
+ if (finfo.name[0] == '.'
+ && (finfo.name[1] == '\0'
+ || (finfo.name[1] == '.' && finfo.name[2] == '\0')))
+ /* skip the "." and ".." */
+ continue;
 
- SVN_ERR ((*walk_func) (walk_baton,
- dirname,
- &finfo,
- subpool));
-
- /* done with this entry; move to next */
- continue;
- }
- else if (finfo.name[1] == '.' && finfo.name[2] == '\0')
- {
- /* skip the parent directory; move to next */
- continue;
- }
- }
-
           /* some other directory. recurse. it will be passed to the
              callback inside the recursion. */
           SVN_ERR (svn_path_cstring_to_utf8 (&name_utf8, finfo.name,

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Feb 17 18:02:54 2004

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.