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


C++ StHandle::getBuffer方法代码示例

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


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

示例1: open

void StPlayList::open(const StCString& thePath,
                      const StCString& theItem) {
    StMutexAuto anAutoLock(myMutex);

    // check if it is recently played playlist
    bool hasTarget = !theItem.isEmpty();
    StString aTarget = hasTarget ? theItem : thePath;
    if(!hasTarget) {
        for(size_t anIter = 0; anIter < myRecent.size(); ++anIter) {
            const StHandle<StRecentItem>& aRecent = myRecent[anIter];
            const StHandle<StFileNode>&   aFile   = aRecent->File;
            if(aFile->size() != 1) {
                continue;
            }

            if(thePath.isEquals(aFile->getPath())) {
                hasTarget = true;
                aTarget = aFile->getValue(0)->getSubPath();
                break;
            }
        }
    }

    clear();
    int aSearchDeep = myRecursionDeep;
    StString aFolderPath;
    StString aFileName;
    if(StFolder::isFolder(thePath)) {
        // add all files from the folder and subfolders
        aFolderPath = thePath;
        aSearchDeep = myRecursionDeep;
        myPlsFile   = addRecentFile(StFileNode(thePath)); // append to recent files list
    } else if(StFileNode::isFileExists(thePath)) {
        // search only current folder
        StFileNode::getFolderAndFile(thePath, aFolderPath, aFileName);
        aSearchDeep = 1;
        bool hasSupportedExt = false;
        StString anExt = StFileNode::getExtension(aFileName);
        for(size_t anExtId = 0; anExtId < myExtensions.size() && !hasSupportedExt; ++anExtId) {
            hasSupportedExt = anExt.isEqualsIgnoreCase(myExtensions[anExtId]);
        }

        // parse m3u playlist
        if(anExt.isEqualsIgnoreCase(stCString("m3u"))
        || anExt.isEqualsIgnoreCase(stCString("m3u8"))) {
            StHandle<StRawFile> aRawFile = new StRawFile(thePath);
            if(aRawFile->readFile()) {
                StFolder* aPlsFolder = new StFolder(aFolderPath, &myFoldersRoot);
                myFoldersRoot.add(aPlsFolder);

                StString aTitle;
                for(char* anIter = skipBOM((char* )aRawFile->getBuffer()); anIter != NULL;) {
                    anIter = parseM3UIter(anIter, aPlsFolder, aTitle);
                }
                aRawFile.nullify();

                if(myFirst != nullptr
                && myFirst->getNext() == nullptr) {
                    const StString aFirstPath = myFirst->getPath();
                    StString anItemExt = StFileNode::getExtension(aFirstPath);
                    if(anItemExt.isEqualsIgnoreCase(stCString("m3u"))
                    || anItemExt.isEqualsIgnoreCase(stCString("m3u8"))) {
                        aRawFile = new StRawFile(aFirstPath);
                        if(aRawFile->readFile()) {
                            for(char* anIter = skipBOM((char* )aRawFile->getBuffer()); anIter != NULL;) {
                                anIter = parseM3UIter(anIter, NULL, aTitle);
                            }
                            remove(aFirstPath, false);
                        }
                        aRawFile.nullify();
                    }
                }

                myPlsFile = addRecentFile(StFileNode(thePath)); // append to recent files list
                if(hasTarget) {
                    // set current item
                    for(StPlayItem* anItem = myFirst; anItem != NULL; anItem = anItem->getNext()) {
                        if(anItem->getPath() == aTarget) {
                            myCurrent = anItem;
                            break;
                        }
                    }
                }

                anAutoLock.unlock();
                signals.onPlaylistChange();
                return;
            }
        }

        if(!hasSupportedExt) {
            // file with unsupported extension?
            StFileNode* aFileNode = new StFileNode(thePath, &myFoldersRoot);
            myFoldersRoot.add(aFileNode);
            addPlayItem(new StPlayItem(aFileNode, myDefStParams));
        }
    } else {
        // not a filesystem element - probably url or invalid path
        StFileNode* aFileNode = new StFileNode(thePath, &myFoldersRoot);
        myFoldersRoot.add(aFileNode);
//.........这里部分代码省略.........
开发者ID:zodsoft,项目名称:sview,代码行数:101,代码来源:StPlayList.cpp


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