本文整理汇总了C++中CFile::GetFileDir方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::GetFileDir方法的具体用法?C++ CFile::GetFileDir怎么用?C++ CFile::GetFileDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::GetFileDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFile
QString CTorrent::GetSubFilePath(int Index)
{
const QList<CTorrentInfo::SFileInfo>& Files = m_TorrentInfo->GetFiles();
if(Files.size() <= Index)
return "";
CFile * pFile = GetFile();
QString Dir = pFile->GetFileDir();
Dir += pFile->GetFileName() + "/";
if(!Files[Index].FilePath.isEmpty())
Dir += Files[Index].FilePath.join("/") + "/";
return Dir;
}
示例2: SetupPartMap
void CTorrent::SetupPartMap()
{
ASSERT(!m_TorrentInfo->IsEmpty());
CFile* pFile = GetFile();
// Single File
if(!m_TorrentInfo->IsMultiFile())
{
if(!pFile->GetPartMap())
pFile->SetPartMap(CPartMapPtr(new CSynced<CPartMap>(m_TorrentInfo->GetTotalLength())));
return;
}
// Multi File:
CJoinedPartMap* pParts = qobject_cast<CJoinedPartMap*>(pFile->GetPartMap());
if(pParts)
{
ASSERT(!pParts->GetLinks().isEmpty());
return; // is already set up
}
pParts = new CJoinedPartMap(pFile->GetFileSize());
pFile->GetInspector()->SetIndexSource(HashTorrent);
CFileList* pList = pFile->GetList();
uint64 Offset = 0;
foreach(const CTorrentInfo::SFileInfo& SubFile, m_TorrentInfo->GetFiles())
{
if(SubFile.Length == 0)
{
LogLine(LOG_DEBUG | LOG_WARNING, tr("Ignoring empty file '%1' in torrent '%2'").arg(SubFile.FileName).arg(pFile->GetFileName()));
continue;
}
CFile* pSubFile = new CFile();
if(pFile->GetProperty("Temp").toBool())
pSubFile->SetProperty("Temp", true);
QString Dir = pFile->GetFileDir();
Dir += pFile->GetFileName() + "/";
if(!SubFile.FilePath.isEmpty())
Dir += SubFile.FilePath.join("/") + "/";
pSubFile->SetFileDir(Dir);
pSubFile->AddEmpty(HashTorrent, SubFile.FileName, SubFile.Length, pFile->IsPending());
// Note: SubFile->MasterHash is set in MasterFile->Resume
uint64 uBegin = Offset;
uint64 uEnd = Offset + SubFile.Length;
Offset += SubFile.Length;
CSharedPartMap* pSubParts = new CSharedPartMap(uEnd - uBegin);
pSubFile->SetPartMap(CPartMapPtr(pSubParts));
pParts->SetupLink(uBegin, uEnd, pSubFile->GetFileID());
pSubParts->SetupLink(uBegin, uEnd, pFile->GetFileID());
pList->AddFile(pSubFile);
if(!pSubFile->IsPending())
pSubFile->Resume();
if(pFile->IsPaused(true))
pSubFile->Pause();
else if(pFile->IsStarted())
pSubFile->Start();
}
pFile->SetPartMap(CPartMapPtr(pParts));
}