18 #if !defined(DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680)
19 #define DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680
44 #include "xercesc/framework/MemoryManager.hpp"
58 using xercesc::MemoryManager;
64 struct FindFileStruct :
public _wfinddata_t
69 eAttributeArchive = _A_ARCH,
70 eAttributeDirectory = _A_SUBDIR,
71 eAttributeHidden = _A_HIDDEN,
72 eAttributeNormal = _A_NORMAL,
73 eReadOnly = _A_RDONLY,
87 return const_cast<XalanDOMChar*
>(
reinterpret_cast<const XalanDOMChar*
>(&name[0]));
98 return attrib & eAttributeDirectory ? true :
false;
102 isSelfOrParent()
const
104 if (isDirectory() ==
false)
108 else if (name[0] ==
'.')
114 else if (name[1] ==
'.' &&
154 #if defined(__SunOS_5_10) && (__SUNPRO_CC >= 0x570)
155 struct stat64 stat_Info;
157 const int retCode = stat64(d_name, &stat_Info);
159 struct stat stat_Info;
161 const int retCode = stat(d_name, &stat_Info);
164 return retCode == -1 ? false : S_ISDIR(stat_Info.st_mode);
170 if (isDirectory() ==
false)
174 else if (d_name[0] ==
'.')
176 if (d_name[1] ==
'\0')
180 else if (d_name[1] ==
'.' &&
206 return theFindData.isDirectory();
219 return !theDirectoryPredicate(theFindData);
226 template<
class OutputIteratorType,
227 class FilterPredicateType,
229 class StringConversionFunction>
232 MemoryManager& theMemoryManager,
233 const StringType& theFullSearchSpec,
234 OutputIteratorType theOutputIterator,
235 FilterPredicateType theFilterPredicate,
236 StringConversionFunction theConversionFunction,
237 #
if defined(XALAN_TEMPLATE_FUNCTION_NO_DEFAULT_PARAMETERS)
238 bool fIncludeSelfAndParent)
240 bool fIncludeSelfAndParent =
false)
243 #if defined(_MSC_VER)
247 typedef intptr_t theHandleType;
249 typedef long theHandleType;
252 #pragma warning(push)
253 #pragma warning(disable: 4244)
254 theHandleType theSearchHandle =
256 reinterpret_cast<wchar_t*
>(
const_cast<XalanDOMChar*
>(theConversionFunction(theFullSearchSpec))),
260 if (theSearchHandle != -1)
267 if ((fIncludeSelfAndParent ==
true || theFindData.isSelfOrParent() ==
false) &&
268 theFilterPredicate(theFindData) ==
true)
270 *theOutputIterator = StringType(theFindData.getName(), theMemoryManager);
273 while(_wfindnext(theSearchHandle,
278 _findclose(theSearchHandle);
283 _findclose(theSearchHandle);
294 int indexSuffix=0, indexName=0;
295 bool target_Dir =
false;
299 if (theTargetVector.
back() ==
'*')
314 while(theTargetVector.
back() !=
'*')
321 while(theTargetVector.
back() !=
'/')
330 const char*
const theSpec =
c_str(theTargetVector);
331 assert(theSpec != 0);
339 int lenSpec = strlen(theSpec);
340 theFullSearchSpec.substr(theName, lenSpec, indexName);
341 theFullSearchSpec.substr(theSuffix, lenSpec+indexName+1, indexSuffix);
344 DIR*
const theDirectory = opendir(theSpec);
346 if (theDirectory != 0)
356 if ((fIncludeSelfAndParent ==
true || theEntry->isSelfOrParent() ==
false))
358 if (theFilterPredicate(*theEntry) ==
true)
362 *theOutputIterator = StringType(theEntry->getName(), theMemoryManager);
367 int Check_1 = Getname.
compare(theName);
369 Getname.
substr(GetnameSuffix, Getname.
size() -indexSuffix, indexSuffix);
370 int Check_2 = GetnameSuffix.
compare(theSuffix);
371 if ( Check_1 == 1 && (!Check_2) )
373 *theOutputIterator = StringType(theEntry->getName(), theMemoryManager);
384 closedir(theDirectory);
392 closedir(theDirectory);
401 template<
class OutputIteratorType,
402 class FilterPredicateType,
404 class StringConversionFunction>
407 MemoryManager& theMemoryManager,
408 const StringType& theDirectory,
409 const StringType& theSearchSpec,
410 OutputIteratorType theOutputIterator,
411 FilterPredicateType theFilterPredicate,
412 StringConversionFunction theConversionFunction,
413 #
if defined(XALAN_TEMPLATE_FUNCTION_NO_DEFAULT_PARAMETERS)
414 bool fIncludeSelfAndParent)
416 bool fIncludeSelfAndParent =
false)
419 StringType theFullSearchSpec(theDirectory, theMemoryManager);
421 theFullSearchSpec += theSearchSpec;
428 theConversionFunction,
429 fIncludeSelfAndParent);
434 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
435 template<
class CollectionType,
class StringType>
436 struct DirectoryEnumeratorFunctor
439 operator()(
const StringType& theDirectory)
const
441 CollectionType theCollection;
443 operator()(theDirectory,
446 return theCollection;
452 const CollectionType&)
const
457 template<
class CollectionType,
458 class StringType = XalanDOMString,
459 class FilterPredicateType = FilesOnlyFilterPredicate,
460 class StringConversionFunction = c_wstr_functor>
465 MemoryManager& theMemoryManager,
466 bool fIncludeSelfAndParent =
false) :
467 m_includeSelfAndParent(fIncludeSelfAndParent),
468 m_memoryManager(theMemoryManager)
474 const StringType& theFullSearchSpec,
475 CollectionType& theCollection)
const
477 using std::back_inserter;
482 std::back_inserter(theCollection),
484 m_conversionFunction,
485 m_includeSelfAndParent);
491 CollectionType theCollection;
497 return theCollection;
502 const StringType& theDirectory,
503 const StringType& theSearchSpec,
504 CollectionType& theCollection)
const
510 std::back_inserter(theCollection),
512 m_conversionFunction,
513 m_includeSelfAndParent);
518 const StringType& theDirectory,
519 const StringType& theSearchSpec)
const
521 CollectionType theCollection;
528 return theCollection;
533 FilterPredicateType m_filterPredicate;
535 StringConversionFunction m_conversionFunction;
537 const bool m_includeSelfAndParent;
539 MemoryManager& m_memoryManager;
549 #endif // DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680