dbertoni    01/02/08 13:36:35

  Modified:    c/src/PlatformSupport DirectoryEnumerator.hpp
  Log:
  Added options to exclude "." and ".." from directory enumeration.
  
  Revision  Changes    Path
  1.20      +49 -6     xml-xalan/c/src/PlatformSupport/DirectoryEnumerator.hpp
  
  Index: DirectoryEnumerator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DirectoryEnumerator.hpp,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- DirectoryEnumerator.hpp   2001/02/07 18:41:10     1.19
  +++ DirectoryEnumerator.hpp   2001/02/08 21:36:30     1.20
  @@ -78,6 +78,7 @@
   
   
   #include <PlatformSupport/DOMStringHelper.hpp>
  +#include <PlatformSupport/XalanUnicode.hpp>
   
   
   
  @@ -120,6 +121,34 @@
                return attrib & eAttributeDirectory ? true : false;
        }
   
  +     bool
  +     isSelfOrParent() const
  +     {
  +             if (isDirectory() == false)
  +             {
  +                     return false;
  +             }
  +             else if (name[0] == XalanUnicode::charFullStop)
  +             {
  +                     if (name[1] == 0)
  +                     {
  +                             return true;
  +                     }
  +                     else if (name[1] == XalanUnicode::charFullStop &&
  +                                      name[2] == 0)
  +                     {
  +                             return true;
  +                     }
  +                     else
  +                     {
  +                             return false;
  +                     }
  +             }
  +             else
  +             {
  +                     return false;
  +             }
  +     }
   };
   
   #else
  @@ -199,7 +228,8 @@
                        const StringType&                       
theFullSearchSpec,
                        OutputIteratorType                      
theOutputIterator,
                        FilterPredicateType                     
theFilterPredicate,
  -                     StringConversionFunction        theConversionFunction)
  +                     StringConversionFunction        theConversionFunction,
  +                     bool                                            
fIncludeSelfAndParent = false)
   {
   #if defined(_MSC_VER)
        FindFileStruct          theFindData;
  @@ -213,7 +243,8 @@
                {
                        do
                        {
  -                             if (theFilterPredicate(theFindData) == true)
  +                             if ((fIncludeSelfAndParent == true || 
theFindData.isSelfOrParent() == false) &&
  +                                     theFilterPredicate(theFindData) == true)
                                {
                                        *theOutputIterator = 
StringType(theFindData.getName());
                                }
  @@ -250,13 +281,14 @@
                        const StringType&                       theSearchSpec,
                        OutputIteratorType                      
theOutputIterator,
                        FilterPredicateType                     
theFilterPredicate,
  -                     StringConversionFunction        theConversionFunction)
  +                     StringConversionFunction        theConversionFunction,
  +                     bool                                            
fIncludeSelfAndParent = false)
   {
        StringType      theFullSearchSpec(theDirectory);
   
        theFullSearchSpec += theSearchSpec;
   
  -     EnumerateDirectory(theFullSearchSpec, theOutputIterator, 
theFilterPredicate, theConversionFunction);
  +     EnumerateDirectory(theFullSearchSpec, theOutputIterator, 
theFilterPredicate, theConversionFunction, fIncludeSelfAndParent);
   }
   
   
  @@ -303,6 +335,12 @@
        typedef typename BaseClassType::result_type             result_type;
        typedef typename BaseClassType::argument_type   argument_type;
   
  +     explicit
  +     DirectoryEnumeratorFunctor(bool         fIncludeSelfAndParent = false) :
  +             m_includeSelfAndParent(fIncludeSelfAndParent)
  +     {
  +     }
  +                     
        void
        operator()(
                        const argument_type&    theFullSearchSpec,
  @@ -315,7 +353,8 @@
                EnumerateDirectory(theFullSearchSpec,
                                                   back_inserter(theCollection),
                                                   m_filterPredicate,
  -                                                m_conversionFunction);
  +                                                m_conversionFunction,
  +                                                m_includeSelfAndParent);
        }
   
        result_type
  @@ -345,7 +384,8 @@
                                theSearchSpec,
                                back_inserter(theCollection),
                                m_filterPredicate,
  -                             m_conversionFunction);
  +                             m_conversionFunction,
  +                             m_includeSelfAndParent);
        }
   
        result_type
  @@ -366,7 +406,10 @@
   private:
   
        FilterPredicateType                     m_filterPredicate;
  +
        StringConversionFunction        m_conversionFunction;
  +
  +     const bool                                      m_includeSelfAndParent;
   };
   #endif
   
  
  
  

Reply via email to