16 #if !defined(DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680)
17 #define DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680
41 #include "xercesc/framework/MemoryManager.hpp"
51 XALAN_CPP_NAMESPACE_BEGIN
55 XALAN_USING_XERCES(MemoryManager)
66 eAttributeArchive = _A_ARCH,
67 eAttributeDirectory = _A_SUBDIR,
68 eAttributeHidden = _A_HIDDEN,
69 eAttributeNormal = _A_NORMAL,
70 eReadOnly = _A_RDONLY,
95 return attrib & eAttributeDirectory ?
true :
false;
105 else if (name[0] ==
'.')
111 else if (name[1] ==
'.' &&
151 #if defined(__SunOS_5_10) && (__SUNPRO_CC >= 0x570)
152 struct stat64 stat_Info;
154 const int retCode = stat64(d_name, &stat_Info);
156 struct stat stat_Info;
158 const int retCode = stat(d_name, &stat_Info);
161 return retCode == -1 ?
false : S_ISDIR(stat_Info.st_mode);
171 else if (d_name[0] ==
'.')
173 if (d_name[1] ==
'\0')
177 else if (d_name[1] ==
'.' &&
198 #if defined(XALAN_NO_STD_NAMESPACE)
207 return theFindData.isDirectory();
213 #if defined(XALAN_NO_STD_NAMESPACE)
224 return !theDirectoryPredicate(theFindData);
231 template<
class OutputIteratorType,
232 class FilterPredicateType,
234 class StringConversionFunction>
237 MemoryManager& theMemoryManager,
238 const StringType& theFullSearchSpec,
239 OutputIteratorType theOutputIterator,
240 FilterPredicateType theFilterPredicate,
241 StringConversionFunction theConversionFunction,
243 bool fIncludeSelfAndParent)
245 bool fIncludeSelfAndParent =
false)
248 #if defined(_MSC_VER)
252 typedef intptr_t theHandleType;
254 typedef long theHandleType;
257 #pragma warning(push)
258 #pragma warning(disable: 4244)
259 theHandleType theSearchHandle =
261 const_cast<wchar_t*>(theConversionFunction(theFullSearchSpec)),
265 if (theSearchHandle != -1)
272 if ((fIncludeSelfAndParent ==
true || theFindData.
isSelfOrParent() ==
false) &&
273 theFilterPredicate(theFindData) ==
true)
275 *theOutputIterator = StringType(theFindData.
getName(), theMemoryManager);
278 while(_wfindnext(theSearchHandle,
283 _findclose(theSearchHandle);
288 _findclose(theSearchHandle);
299 int indexSuffix=0, indexName=0;
300 bool target_Dir =
false;
304 if (theTargetVector.
back() ==
'*')
319 while(theTargetVector.
back() !=
'*')
326 while(theTargetVector.
back() !=
'/')
335 const char*
const theSpec =
c_str(theTargetVector);
336 assert(theSpec != 0);
342 #if defined(XALAN_STRICT_ANSI_HEADERS)
346 int lenSpec = strlen(theSpec);
347 theFullSearchSpec.substr(theName, lenSpec, indexName);
348 theFullSearchSpec.substr(theSuffix, lenSpec+indexName+1, indexSuffix);
351 DIR*
const theDirectory = opendir(theSpec);
353 if (theDirectory != 0)
363 if ((fIncludeSelfAndParent ==
true || theEntry->
isSelfOrParent() ==
false))
365 if (theFilterPredicate(*theEntry) ==
true)
369 *theOutputIterator = StringType(theEntry->
getName(), theMemoryManager);
374 int Check_1 = Getname.
compare(theName);
376 Getname.substr(GetnameSuffix, Getname.
size() -indexSuffix, indexSuffix);
377 int Check_2 = GetnameSuffix.
compare(theSuffix);
378 if ( Check_1 == 1 && (!Check_2) )
380 *theOutputIterator = StringType(theEntry->
getName(), theMemoryManager);
391 closedir(theDirectory);
399 closedir(theDirectory);
408 template<
class OutputIteratorType,
409 class FilterPredicateType,
411 class StringConversionFunction>
414 MemoryManager& theMemoryManager,
415 const StringType& theDirectory,
416 const StringType& theSearchSpec,
417 OutputIteratorType theOutputIterator,
418 FilterPredicateType theFilterPredicate,
419 StringConversionFunction theConversionFunction,
421 bool fIncludeSelfAndParent)
423 bool fIncludeSelfAndParent =
false)
426 StringType theFullSearchSpec(theDirectory, theMemoryManager);
428 theFullSearchSpec += theSearchSpec;
435 theConversionFunction,
436 fIncludeSelfAndParent);
441 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
442 template<
class CollectionType,
class StringType>
446 operator()(
const StringType& theDirectory)
const
448 CollectionType theCollection;
453 return theCollection;
459 const CollectionType&)
const
464 template<
class CollectionType,
468 #if defined(XALAN_NO_STD_NAMESPACE)
474 #if defined(XALAN_NO_STD_NAMESPACE)
475 typedef unary_function<StringType, CollectionType>
BaseClassType;
485 MemoryManager& theMemoryManager,
486 bool fIncludeSelfAndParent =
false) :
487 m_includeSelfAndParent(fIncludeSelfAndParent),
488 m_memoryManager(theMemoryManager)
495 CollectionType& theCollection)
const
497 XALAN_USING_STD(back_inserter)
502 XALAN_STD_QUALIFIER back_inserter(theCollection),
504 m_conversionFunction,
505 m_includeSelfAndParent);
517 return theCollection;
524 CollectionType& theCollection)
const
530 XALAN_STD_QUALIFIER back_inserter(theCollection),
532 m_conversionFunction,
533 m_includeSelfAndParent);
548 return theCollection;
553 FilterPredicateType m_filterPredicate;
555 StringConversionFunction m_conversionFunction;
557 const bool m_includeSelfAndParent;
559 MemoryManager& m_memoryManager;
565 XALAN_CPP_NAMESPACE_END
569 #endif // DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680