本文整理汇总了C++中CFileItemList::GetFastLookup方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemList::GetFastLookup方法的具体用法?C++ CFileItemList::GetFastLookup怎么用?C++ CFileItemList::GetFastLookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemList
的用法示例。
在下文中一共展示了CFileItemList::GetFastLookup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDirectory
bool CZipDirectory::GetDirectory(const CStdString& strPathOrig, CFileItemList& items)
{
CStdString strPath;
/* if this isn't a proper archive path, assume it's the path to a archive file */
if( !strPathOrig.Left(6).Equals("zip://") )
URIUtils::CreateArchivePath(strPath, "zip", strPathOrig, "");
else
strPath = strPathOrig;
CURL url(strPath);
CStdString strArchive = url.GetHostName();
CStdString strOptions = url.GetOptions();
CStdString strPathInZip = url.GetFileName();
url.SetOptions(""); // delete options to have a clean path to add stuff too
url.SetFileName(""); // delete filename too as our names later will contain it
CStdString strSlashPath = url.Get();
CStdString strBuffer;
// the RAR code depends on things having a "/" at the end of the path
URIUtils::AddSlashAtEnd(strSlashPath);
vector<SZipEntry> entries;
// turn on fast lookups
bool bWasFast(items.GetFastLookup());
items.SetFastLookup(true);
if (!g_ZipManager.GetZipList(strPath,entries))
return false;
vector<CStdString> baseTokens;
if (!strPathInZip.IsEmpty())
CUtil::Tokenize(strPathInZip,baseTokens,"/");
for (vector<SZipEntry>::iterator ze=entries.begin(); ze!=entries.end(); ++ze)
{
CStdString strEntryName(ze->name);
strEntryName.Replace('\\','/');
if (strEntryName == strPathInZip) // skip the listed dir
continue;
vector<CStdString> pathTokens;
CUtil::Tokenize(strEntryName,pathTokens,"/");
if (pathTokens.size() < baseTokens.size()+1)
continue;
bool bAdd=true;
strEntryName = "";
for ( unsigned int i=0; i<baseTokens.size(); ++i )
{
if (pathTokens[i] != baseTokens[i])
{
bAdd = false;
break;
}
strEntryName += pathTokens[i] + "/";
}
if (!bAdd)
continue;
strEntryName += pathTokens[baseTokens.size()];
char c=ze->name[strEntryName.size()];
if (c == '/' || c == '\\')
strEntryName += '/';
bool bIsFolder = false;
if (strEntryName[strEntryName.size()-1] != '/') // this is a file
{
strBuffer = strSlashPath + strEntryName + strOptions;
}
else
{ // this is new folder. add if not already added
bIsFolder = true;
strBuffer = strSlashPath + strEntryName + strOptions;
if (items.Contains(strBuffer)) // already added
continue;
}
CFileItemPtr pFileItem(new CFileItem);
if (g_charsetConverter.isValidUtf8(pathTokens[baseTokens.size()]))
g_charsetConverter.utf8ToStringCharset(pathTokens[baseTokens.size()]);
pFileItem->SetLabel(pathTokens[baseTokens.size()]);
if (bIsFolder)
{
pFileItem->m_dwSize = 0;
URIUtils::AddSlashAtEnd(strBuffer);
}
else
pFileItem->m_dwSize = ze->usize;
pFileItem->SetPath(strBuffer);
pFileItem->m_bIsFolder = bIsFolder;
pFileItem->m_idepth = ze->method;
items.Add(pFileItem);
}
items.SetFastLookup(bWasFast);
return true;
//.........这里部分代码省略.........