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


C++ CFile::IsComplete方法代码示例

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


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

示例1: LoadTorrentFromFile

bool CTorrent::LoadTorrentFromFile(const QByteArray& InfoHash)
{
    ASSERT(m_TorrentInfo == NULL);
    m_TorrentInfo = new CTorrentInfo(this);

    ASSERT(m_pHash.isNull());
    m_pHash = CFileHashPtr(new CFileHash(HashTorrent));
    m_pHash->SetHash(InfoHash);

    QString TorrentFile = QString(InfoHash.toHex()) + ".torrent";

    if(m_TorrentInfo->LoadTorrentFile(theCore->m_TorrentManager->GetTorrentDir() + TorrentFile))
    {
        if(m_TorrentInfo->GetInfoHash() == InfoHash)
        {
            CFile* pFile = GetFile();

            if(pFile->GetFileSize() == 0)
                pFile->SetFileSize(m_TorrentInfo->GetTotalLength());

            LoadPieceHashes();

            if(m_TorrentInfo->IsMultiFile() && !pFile->IsMultiFile())
            {
                CFileHashPtr pMasterHash = pFile->GetMasterHash();
                if(!pMasterHash.isNull() && pMasterHash->GetHash() == InfoHash)
                {
                    LogLine(LOG_DEBUG | LOG_ERROR, tr("The multi file %1 is missing its proper index, restoring form torrent").arg(pFile->GetFileName()));
                    InstallMetadata();
                }
            }

            if(!m_TorrentInfo->IsEmpty() && !pFile->IsComplete() && !pFile->GetPartMap())
                SetupPartMap();
        }
        else
        {
            LogLine(LOG_DEBUG | LOG_ERROR, tr("The torrent file %1 contains an invalid infohash").arg(TorrentFile));
            delete m_TorrentInfo;
            m_TorrentInfo = new CTorrentInfo(this);
            m_TorrentInfo->SetInfoHash(InfoHash);
        }
    }
    else
        m_TorrentInfo->SetInfoHash(InfoHash);
    theCore->m_TorrentManager->RegisterInfoHash(m_TorrentInfo->GetInfoHash());

    return true; // Note: that is always true even if we fail to load as we always wil be able to proceed one way or another
}
开发者ID:supertanglang,项目名称:NeoLoader,代码行数:49,代码来源:Torrent.cpp

示例2: InstallMetadata

bool CTorrent::InstallMetadata()
{
    CFile* pFile = GetFile();

    ASSERT(m_TorrentInfo);

    CPartMap* pPartMap = pFile->GetPartMap();
    if(pPartMap && !CompareSubFiles(pPartMap))
    {
        if(pFile->GetInspector()->BadMetaData(GetHash()))
            pPartMap = NULL;
        else
            return false;
    }

    if(m_pHash->Compare(pFile->GetMasterHash().data()))
        pFile->SetFileName(m_TorrentInfo->GetTorrentName());

    bool bOpenIO = false;
    CJoinedPartMap* pJoinedParts = qobject_cast<CJoinedPartMap*>(pPartMap);
    if((pPartMap == NULL && !pFile->IsComplete()) || (pJoinedParts && pJoinedParts->GetLinks().isEmpty()))
    {
        bOpenIO = true;
        if(!pPartMap)
            pFile->SetFileSize(m_TorrentInfo->GetTotalLength());

        SetupPartMap();

        if(!pPartMap && !pFile->IsPending())
            pFile->SetFilePath();
    }

    LoadPieceHashes();

    if(pFile->IsIncomplete() && pFile->GetMasterHash()->GetType() == HashTorrent)
        pFile->CleanUpHashes();

    // Note: if neo is the masterhash the IO is already opened
    if(bOpenIO && !pFile->IsPending())
        pFile->Resume();
    return true;
}
开发者ID:supertanglang,项目名称:NeoLoader,代码行数:42,代码来源:Torrent.cpp

示例3: MakeTorrent

bool CTorrent::MakeTorrent(uint64 uPieceLength, bool bMerkle, const QString& Name, bool bPrivate)
{
    CFile* pFile = GetFile();

    if(!pFile->IsComplete())
    {
        LogLine(LOG_DEBUG | LOG_ERROR, tr("A torrent can not be made form an Incompelte file %1").arg(pFile->GetFileName()));
        return false;
    }

    if(uPieceLength < KB2B(16)) //if(!uPieceLength)
    {
        uPieceLength = pFile->GetFileSize() / (KB2B(40) / 20); // target hast set size 40 KB

        uint64 i = KB2B(16);
        for (; i < MB2B(32); i *= 2)
        {
            if (i >= uPieceLength)
                break;
        }
        uPieceLength = i;
    }

    m_TorrentInfo = new CTorrentInfo(this);
    m_TorrentInfo->SetTorrentName(Name.isEmpty() ? pFile->GetFileName() : Name);
    m_TorrentInfo->SetTotalLength(pFile->GetFileSize());
    if(bPrivate)
        m_TorrentInfo->SetPrivate();

    m_TorrentInfo->SetProperty("CreationTime", QDateTime::currentDateTime());

    ASSERT(m_pHash.isNull());
    if(bMerkle)
        m_pHash = CFileHashPtr(new CFileHashTree(HashTorrent, m_TorrentInfo->GetTotalLength(), uPieceLength));
    else
        m_pHash = CFileHashPtr(new CFileHashSet(HashTorrent, m_TorrentInfo->GetTotalLength(), uPieceLength));
    return true;
}
开发者ID:supertanglang,项目名称:NeoLoader,代码行数:38,代码来源:Torrent.cpp


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