18 #if !defined(DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680) 19 #define DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680 44 #include "xercesc/framework/MemoryManager.hpp" 54 XALAN_CPP_NAMESPACE_BEGIN
69 eAttributeArchive = _A_ARCH,
70 eAttributeDirectory = _A_SUBDIR,
71 eAttributeHidden = _A_HIDDEN,
72 eAttributeNormal = _A_NORMAL,
73 eReadOnly = _A_RDONLY,
98 return attrib & eAttributeDirectory ? true :
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);
174 else if (d_name[0] ==
'.')
176 if (d_name[1] ==
'\0')
180 else if (d_name[1] ==
'.' &&
201 #if defined(XALAN_NO_STD_NAMESPACE) 210 return theFindData.isDirectory();
216 #if defined(XALAN_NO_STD_NAMESPACE) 227 return !theDirectoryPredicate(theFindData);
234 template<
class OutputIteratorType,
235 class FilterPredicateType,
237 class StringConversionFunction>
240 MemoryManager& theMemoryManager,
241 const StringType& theFullSearchSpec,
242 OutputIteratorType theOutputIterator,
243 FilterPredicateType theFilterPredicate,
244 StringConversionFunction theConversionFunction,
245 #
if defined(XALAN_TEMPLATE_FUNCTION_NO_DEFAULT_PARAMETERS)
246 bool fIncludeSelfAndParent)
248 bool fIncludeSelfAndParent =
false)
251 #if defined(_MSC_VER) 255 typedef intptr_t theHandleType;
257 typedef long theHandleType;
260 #pragma warning(push) 261 #pragma warning(disable: 4244) 262 theHandleType theSearchHandle =
264 const_cast<wchar_t*>(theConversionFunction(theFullSearchSpec)),
268 if (theSearchHandle != -1)
275 if ((fIncludeSelfAndParent ==
true || theFindData.
isSelfOrParent() ==
false) &&
276 theFilterPredicate(theFindData) ==
true)
278 *theOutputIterator = StringType(theFindData.
getName(), theMemoryManager);
281 while(_wfindnext(theSearchHandle,
286 _findclose(theSearchHandle);
291 _findclose(theSearchHandle);
302 int indexSuffix=0, indexName=0;
303 bool target_Dir =
false;
307 if (theTargetVector.
back() ==
'*')
322 while(theTargetVector.
back() !=
'*')
329 while(theTargetVector.
back() !=
'/')
338 const char*
const theSpec =
c_str(theTargetVector);
339 assert(theSpec != 0);
345 #if defined(XALAN_STRICT_ANSI_HEADERS) 349 int lenSpec = strlen(theSpec);
350 theFullSearchSpec.substr(theName, lenSpec, indexName);
351 theFullSearchSpec.substr(theSuffix, lenSpec+indexName+1, indexSuffix);
354 DIR*
const theDirectory = opendir(theSpec);
356 if (theDirectory != 0)
366 if ((fIncludeSelfAndParent ==
true || theEntry->
isSelfOrParent() ==
false))
368 if (theFilterPredicate(*theEntry) ==
true)
372 *theOutputIterator = StringType(theEntry->
getName(), theMemoryManager);
377 int Check_1 = Getname.
compare(theName);
379 Getname.substr(GetnameSuffix, Getname.
size() -indexSuffix, indexSuffix);
380 int Check_2 = GetnameSuffix.
compare(theSuffix);
381 if ( Check_1 == 1 && (!Check_2) )
383 *theOutputIterator = StringType(theEntry->
getName(), theMemoryManager);
394 closedir(theDirectory);
402 closedir(theDirectory);
411 template<
class OutputIteratorType,
412 class FilterPredicateType,
414 class StringConversionFunction>
417 MemoryManager& theMemoryManager,
418 const StringType& theDirectory,
419 const StringType& theSearchSpec,
420 OutputIteratorType theOutputIterator,
421 FilterPredicateType theFilterPredicate,
422 StringConversionFunction theConversionFunction,
423 #
if defined(XALAN_TEMPLATE_FUNCTION_NO_DEFAULT_PARAMETERS)
424 bool fIncludeSelfAndParent)
426 bool fIncludeSelfAndParent =
false)
429 StringType theFullSearchSpec(theDirectory, theMemoryManager);
431 theFullSearchSpec += theSearchSpec;
438 theConversionFunction,
439 fIncludeSelfAndParent);
444 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS) 445 template<
class CollectionType,
class StringType>
449 operator()(
const StringType& theDirectory)
const 451 CollectionType theCollection;
453 operator()(theDirectory,
456 return theCollection;
462 const CollectionType&)
const 467 template<
class CollectionType,
471 #if defined(XALAN_NO_STD_NAMESPACE) 477 #if defined(XALAN_NO_STD_NAMESPACE) 478 typedef unary_function<StringType, CollectionType>
BaseClassType;
488 MemoryManager& theMemoryManager,
489 bool fIncludeSelfAndParent =
false) :
490 m_includeSelfAndParent(fIncludeSelfAndParent),
491 m_memoryManager(theMemoryManager)
497 const argument_type& theFullSearchSpec,
498 CollectionType& theCollection)
const 500 XALAN_USING_STD(back_inserter)
505 XALAN_STD_QUALIFIER back_inserter(theCollection),
507 m_conversionFunction,
508 m_includeSelfAndParent);
514 result_type theCollection;
520 return theCollection;
525 const argument_type& theDirectory,
526 const argument_type& theSearchSpec,
527 CollectionType& theCollection)
const 533 XALAN_STD_QUALIFIER back_inserter(theCollection),
535 m_conversionFunction,
536 m_includeSelfAndParent);
541 const argument_type& theDirectory,
542 const argument_type& theSearchSpec)
const 544 result_type theCollection;
551 return theCollection;
556 FilterPredicateType m_filterPredicate;
558 StringConversionFunction m_conversionFunction;
560 const bool m_includeSelfAndParent;
562 MemoryManager& m_memoryManager;
568 XALAN_CPP_NAMESPACE_END
572 #endif // DIRECTORY_ENUMERATOR_HEADER_GUARD_1357924680 std::unary_function< StringType, CollectionType > BaseClassType
bool isSelfOrParent() const
bool isDirectory() const
Determine whether file is a directory.
int compare(const XalanDOMString &theString) const
void operator()(const argument_type &theFullSearchSpec, CollectionType &theCollection) const
DirectoryEnumeratorFunctor(MemoryManager &theMemoryManager, bool fIncludeSelfAndParent=false)
result_type operator()(const argument_type &theFindData) const
void push_back(const value_type &data)
BaseClassType::result_type result_type
result_type operator()(const argument_type &theFullSearchSpec) const
const char * c_str(const CharVectorType &theString)
Get the underlying representation of the target CharVectorType as a null-terminated string...
const char * getName() const
Retrieve name of file.
void EnumerateDirectory(MemoryManager &theMemoryManager, const StringType &theFullSearchSpec, OutputIteratorType theOutputIterator, FilterPredicateType theFilterPredicate, StringConversionFunction theConversionFunction, bool fIncludeSelfAndParent=false)
void operator()(const argument_type &theDirectory, const argument_type &theSearchSpec, CollectionType &theCollection) const
TranscodeToLocalCodePage(const XalanDOMChar *theSourceString, XalanDOMString::size_type theSourceStringLength, CharVectorType &targetVector, bool terminate=false)
Convert a XalanDOMChar string to C++ standard library vector, transcoding to the default local code p...
BaseClassType::argument_type argument_type
XALAN_CPP_NAMESPACE_BEGIN XALAN_USING_XERCES(Locator)
result_type operator()(const argument_type &theFindData) const
result_type operator()(const argument_type &theDirectory, const argument_type &theSearchSpec) const