当前位置: 首页>>代码示例>>C++>>正文


C++ EntryList::get_allocator方法代码示例

本文整理汇总了C++中EntryList::get_allocator方法的典型用法代码示例。如果您正苦于以下问题:C++ EntryList::get_allocator方法的具体用法?C++ EntryList::get_allocator怎么用?C++ EntryList::get_allocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntryList的用法示例。


在下文中一共展示了EntryList::get_allocator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Read

///////////////////////////////////////////////////////////////////////////////
// Read
//
size_t DirectoryIterator::Read(const char16_t* pDirectory, EntryList& entryList, 
                             const char16_t* pFilterPattern, int nDirectoryEntryFlags, 
                             size_t maxResultCount)
{
    EntryFindData entryFindData, *pEntryFindData;
    size_t        resultCount = 0;

    #if EASTL_NAME_ENABLED // If the EntryList doesn't have a unique name, we give it one here.
        if(entryList.get_allocator().get_name() && !strcmp(EASTL_LIST_DEFAULT_NAME, entryList.get_allocator().get_name()))
            entryList.get_allocator().set_name(ENTRYLIST_NAME);
    #endif

    // Iterate entries.
    for(pEntryFindData = EntryFindFirst(pDirectory, pFilterPattern, &entryFindData); pEntryFindData && (resultCount < maxResultCount); )
    {
        if(!StrEq16(pEntryFindData->mName, EA_DIRECTORY_CURRENT_16) && // If it is neither "./" nor "../"
           !StrEq16(pEntryFindData->mName, EA_DIRECTORY_PARENT_16))
        {
            if(pEntryFindData->mbIsDirectory)
            {
                if(nDirectoryEntryFlags & kDirectoryEntryDirectory)
                {
                    resultCount++;
                    entryList.push_back();
                    entryList.back().mType  = kDirectoryEntryDirectory;
                    entryList.back().msName = pEntryFindData->mName;
                }
            }
            else
            {
                if(nDirectoryEntryFlags & kDirectoryEntryFile)
                {
                    resultCount++;
                    entryList.push_back();
                    entryList.back().mType  = kDirectoryEntryFile;
                    entryList.back().msName = pEntryFindData->mName;
                }
            }
        }

        if(!EntryFindNext(pEntryFindData))
        {
            EntryFindFinish(pEntryFindData);
            break;
        }
    }

    if(pEntryFindData)
    {
        if((nDirectoryEntryFlags & kDirectoryEntryCurrent) && (resultCount < maxResultCount))
        {
            resultCount++;
            entryList.push_front();
            entryList.front().mType  = kDirectoryEntryDirectory;
            entryList.front().msName = EA_DIRECTORY_CURRENT_16;
        }

        if((nDirectoryEntryFlags & kDirectoryEntryParent) && (resultCount < maxResultCount))
        {
            // To do: We don't want to do this if the directory is a root directory.
            resultCount++;
            entryList.push_front();
            entryList.front().mType  = kDirectoryEntryDirectory;
            entryList.front().msName = EA_DIRECTORY_PARENT_16;
        }
    }

    return resultCount;
}
开发者ID:emuikernel,项目名称:EAWebKit,代码行数:72,代码来源:EAFileDirectory.cpp

示例2: ReadRecursive

///////////////////////////////////////////////////////////////////////////////
// ReadRecursive
//
size_t DirectoryIterator::ReadRecursive(const char16_t* pBaseDirectory, EntryList& entryList, 
                                      const char16_t* pFilterPattern, int nEntryTypeFlags, 
                                      bool bIncludeBaseDirectoryInSearch, bool bFullPaths, 
                                      size_t maxResultCount)
{
    EA::IO::Path::PathString16  pathTemp;
    //char16_t pathTemp[kMaxPathLength];

    if(mnRecursionIndex++ == 0) // If being called for the first time...
    {
        #if EASTL_NAME_ENABLED // If the EntryList doesn't have a unique name, we give it one here.
            if(entryList.get_allocator().get_name() && !strcmp(EASTL_LIST_DEFAULT_NAME, entryList.get_allocator().get_name()))
                entryList.get_allocator().set_name(ENTRYLIST_NAME);
        #endif

        mnListSize           = 0;
        mpBaseDirectory      = pBaseDirectory;
        mBaseDirectoryLength = (eastl_size_t)EAIOStrlen16(pBaseDirectory);
        if(!mBaseDirectoryLength || !IsFilePathSeparator(pBaseDirectory[mBaseDirectoryLength - 1]))
            mBaseDirectoryLength++;
    }

    if((nEntryTypeFlags & kDirectoryEntryFile) && 
       (bIncludeBaseDirectoryInSearch || (mnRecursionIndex > 1)) && 
       (mnListSize < maxResultCount))
    {
        // Add all files in the current directory into the list, using the filter pattern.
        const size_t additionCount = Read(pBaseDirectory, entryList, pFilterPattern, kDirectoryEntryFile, maxResultCount - mnListSize);

        EntryList::iterator it(entryList.end());
        eastl::advance(it, -(int32_t)(uint32_t)additionCount);

        for(; it != entryList.end(); ++it)
        {
            Entry& entry = *it;

            mnListSize++;

            const eastl_size_t savedLength = entry.msName.length();
            entry.msName.insert(0, pBaseDirectory);
            const eastl_size_t directoryEnd = entry.msName.length() - savedLength;

            if(directoryEnd && !IsFilePathSeparator(entry.msName[directoryEnd - 1]))
                entry.msName.insert(directoryEnd, 1, kFilePathSeparator16);

            if(!bFullPaths)
                entry.msName.erase(0, mBaseDirectoryLength);
        }
    }

    if(mnListSize < maxResultCount)
    {
        // To do: Find a way to avoid this temporary list.
        // Since the list is only a list of directories under the 
        // current directory, it shouldn't need all that many entries.
        EntryList entryListTemp(entryList.get_allocator());

        // Add all directories in the current directory into the list, ignoring the filter pattern.
        Read(pBaseDirectory, entryListTemp, NULL, kDirectoryEntryDirectory, kMaxEntryCountDefault);

        for(EntryList::iterator it = entryListTemp.begin(); (it != entryListTemp.end()) && (mnListSize < maxResultCount); ++it)
        {
            const Entry& entry = *it; 

            pathTemp.assign( pBaseDirectory );
            EA::IO::Path::Append( pathTemp, entry.msName.c_str() );  // This previously was Join but Join was calling Normalize, which was modifying the pBaseDirectory part of the path string, and we don't want that messed with. Actually we don't need any normalization.

            //ConcatenatePathComponents(pathTemp, pBaseDirectory, entry.msName.c_str());

            // Possibly add this directory to the entry list.
            if(nEntryTypeFlags & kDirectoryEntryDirectory)
            {
                if(!pFilterPattern || FnMatch(pFilterPattern, entry.msName.c_str(), kFNMCaseFold))
                {
                    mnListSize++;
                    entryList.push_back();
                    Entry& listEntry = entryList.back();
                    listEntry.mType  = kDirectoryEntryDirectory;
                    listEntry.msName = pathTemp.c_str();

                    if(!bFullPaths)
                        listEntry.msName.erase(0, mBaseDirectoryLength);
                }
            }

            // Now recursively read the subdirectory.
            ReadRecursive(pathTemp.c_str(), entryList, pFilterPattern, nEntryTypeFlags, true, bFullPaths, maxResultCount);
        }
    }

    mnRecursionIndex--;

    return mnListSize;
}
开发者ID:emuikernel,项目名称:EAWebKit,代码行数:97,代码来源:EAFileDirectory.cpp


注:本文中的EntryList::get_allocator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。