本文整理汇总了C++中CDirectory::GetDirectory方法的典型用法代码示例。如果您正苦于以下问题:C++ CDirectory::GetDirectory方法的具体用法?C++ CDirectory::GetDirectory怎么用?C++ CDirectory::GetDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDirectory
的用法示例。
在下文中一共展示了CDirectory::GetDirectory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FillFileItemList
bool CFileOperations::FillFileItemList(const CVariant ¶meterObject, CFileItemList &list)
{
if (parameterObject.isMember("directory"))
{
CStdString media = parameterObject["media"].asString();
media = media.ToLower();
CStdString strPath = parameterObject["directory"].asString();
if (!strPath.empty())
{
CFileItemList items;
CStdString extensions = "";
CStdStringArray regexps;
if (media.Equals("video"))
{
regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
extensions = g_settings.m_videoExtensions;
}
else if (media.Equals("music"))
{
regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
extensions = g_settings.m_musicExtensions;
}
else if (media.Equals("pictures"))
{
regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;
extensions = g_settings.m_pictureExtensions;
}
CDirectory directory;
if (directory.GetDirectory(strPath, items, extensions))
{
items.Sort(SORT_METHOD_FILE, SortOrderAscending);
CFileItemList filteredDirectories;
for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
{
if (CUtil::ExcludeFileOrFolder(items[i]->GetPath(), regexps))
continue;
if (items[i]->m_bIsFolder)
filteredDirectories.Add(items[i]);
else if ((media == "video" && items[i]->HasVideoInfoTag()) ||
(media == "music" && items[i]->HasMusicInfoTag()))
list.Add(items[i]);
else
{
CFileItem fileItem;
if (FillFileItem(items[i], fileItem, media))
list.Add(CFileItemPtr(new CFileItem(fileItem)));
else if (media == "files")
list.Add(items[i]);
}
}
if (parameterObject.isMember("recursive") && parameterObject["recursive"].isBoolean())
{
for (int i = 0; i < filteredDirectories.Size(); i++)
{
CVariant val = parameterObject;
val["directory"] = filteredDirectories[i]->GetPath();
FillFileItemList(val, list);
}
}
return true;
}
}
}
return false;
}
示例2: GetDirectory
JSON_STATUS CFileOperations::GetDirectory(const CStdString &method, ITransportLayer *transport, IClient *client, const Value ¶meterObject, Value &result)
{
CStdString media = parameterObject["media"].asString();
media = media.ToLower();
CDirectory directory;
CFileItemList items;
CStdString strPath = parameterObject["directory"].asString();
CStdStringArray regexps;
CStdString extensions = "";
if (media.Equals("video"))
{
regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
extensions = g_stSettings.m_videoExtensions;
}
else if (media.Equals("music"))
{
regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
extensions = g_stSettings.m_musicExtensions;
}
else if (media.Equals("pictures"))
{
regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;
extensions = g_stSettings.m_pictureExtensions;
}
if (directory.GetDirectory(strPath, items, extensions))
{
CFileItemList filteredDirectories, filteredFiles;
for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
{
if (CUtil::ExcludeFileOrFolder(items[i]->m_strPath, regexps))
continue;
if (items[i]->IsSmb())
{
CURI url(items[i]->m_strPath);
items[i]->m_strPath = url.GetWithoutUserDetails();
}
if (items[i]->m_bIsFolder)
filteredDirectories.Add(items[i]);
else
filteredFiles.Add(items[i]);
}
// Check if the "fields" list exists
// and make sure it contains the "file"
// field
Value param = parameterObject;
if (!param.isMember("fields"))
param["fields"] = Value(arrayValue);
bool hasFileField = false;
for (unsigned int i = 0; i < param["fields"].size(); i++)
{
if (param["fields"][i].asString().compare("file") == 0)
{
hasFileField = true;
break;
}
}
if (!hasFileField)
param["fields"].append("file");
HandleFileItemList(NULL, true, "files", filteredDirectories, param, result);
for (unsigned int index = 0; index < result["files"].size(); index++)
{
result["files"][index]["filetype"] = "directory";
}
int count = result["limits"]["total"].asInt();
HandleFileItemList(NULL, true, "files", filteredFiles, param, result);
for (unsigned int index = count; index < result["files"].size(); index++)
{
result["files"][index]["filetype"] = "file";
}
count += result["limits"]["total"].asInt();
result["limits"]["end"] = count;
result["limits"]["total"] = count;
result["success"] = true;
return OK;
}
return InvalidParams;
}
示例3: PopulateTrainersList
void CGUIWindowPrograms::PopulateTrainersList()
{
CDirectory directory;
CFileItemList trainers;
CFileItemList archives;
CFileItemList inArchives;
// first, remove any dead items
std::vector<CStdString> vecTrainerPath;
m_database.GetAllTrainers(vecTrainerPath);
CGUIDialogProgress* m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
m_dlgProgress->SetLine(0,12023);
m_dlgProgress->SetLine(1,"");
m_dlgProgress->SetLine(2,"");
m_dlgProgress->StartModal();
m_dlgProgress->SetHeading(12012);
m_dlgProgress->ShowProgressBar(true);
m_dlgProgress->Progress();
bool bBreak=false;
bool bDatabaseState = m_database.IsOpen();
if (!bDatabaseState)
m_database.Open();
m_database.BeginTransaction();
for (unsigned int i=0;i<vecTrainerPath.size();++i)
{
m_dlgProgress->SetPercentage((int)((float)i/(float)vecTrainerPath.size()*100.f));
CStdString strLine;
strLine.Format("%s %i / %i",g_localizeStrings.Get(12013).c_str(), i+1,vecTrainerPath.size());
m_dlgProgress->SetLine(1,strLine);
m_dlgProgress->Progress();
if (!CFile::Exists(vecTrainerPath[i]) || vecTrainerPath[i].find(g_guiSettings.GetString("myprograms.trainerpath",false)) == -1)
m_database.RemoveTrainer(vecTrainerPath[i]);
if (m_dlgProgress->IsCanceled())
{
bBreak = true;
m_database.RollbackTransaction();
break;
}
}
if (!bBreak)
{
CLog::Log(LOGDEBUG,"trainerpath %s",g_guiSettings.GetString("myprograms.trainerpath",false).c_str());
directory.GetDirectory(g_guiSettings.GetString("myprograms.trainerpath").c_str(),trainers,".xbtf|.etm");
if (g_guiSettings.GetString("myprograms.trainerpath",false).IsEmpty())
{
m_database.RollbackTransaction();
m_dlgProgress->Close();
return;
}
directory.GetDirectory(g_guiSettings.GetString("myprograms.trainerpath").c_str(),archives,".rar|.zip",false); // TODO: ZIP SUPPORT
for( int i=0;i<archives.Size();++i)
{
if (stricmp(URIUtils::GetExtension(archives[i]->GetPath()),".rar") == 0)
{
g_RarManager.GetFilesInRar(inArchives,archives[i]->GetPath(),false);
CHDDirectory dir;
dir.SetMask(".xbtf|.etm");
for (int j=0;j<inArchives.Size();++j)
if (dir.IsAllowed(inArchives[j]->GetPath()))
{
CFileItemPtr item(new CFileItem(*inArchives[j]));
CStdString strPathInArchive = item->GetPath();
CStdString path;
URIUtils::CreateArchivePath(path, "rar", archives[i]->GetPath(), strPathInArchive,"");
item->SetPath(path);
trainers.Add(item);
}
}
if (stricmp(URIUtils::GetExtension(archives[i]->GetPath()),".zip")==0)
{
// add trainers in zip
CStdString strZipPath;
URIUtils::CreateArchivePath(strZipPath,"zip",archives[i]->GetPath(),"");
CFileItemList zipTrainers;
directory.GetDirectory(strZipPath,zipTrainers,".etm|.xbtf");
for (int j=0;j<zipTrainers.Size();++j)
{
CFileItemPtr item(new CFileItem(*zipTrainers[j]));
trainers.Add(item);
}
}
}
if (!m_dlgProgress)
m_dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
m_dlgProgress->SetPercentage(0);
m_dlgProgress->ShowProgressBar(true);
CLog::Log(LOGDEBUG,"# trainers %i",trainers.Size());
m_dlgProgress->SetLine(1,"");
int j=0;
while (j < trainers.Size())
{
if (trainers[j]->m_bIsFolder)
trainers.Remove(j);
else
j++;
}
for (int i=0;i<trainers.Size();++i)
//.........这里部分代码省略.........
示例4: FillFileItemList
bool CFileOperations::FillFileItemList(const Value ¶meterObject, CFileItemList &list)
{
if (parameterObject.isObject() && parameterObject.isMember("directory"))
{
CStdString media = "files";
if (parameterObject.isMember("media"))
{
if (parameterObject["media"].isString())
media = parameterObject["media"].asString();
else
return false;
}
media = media.ToLower();
if (media.Equals("video") || media.Equals("music") || media.Equals("pictures") || media.Equals("files") || media.Equals("programs"))
{
CDirectory directory;
CFileItemList items;
CStdString strPath = parameterObject["directory"].asString();
CStdStringArray regexps;
CStdString extensions = "";
if (media.Equals("video"))
{
regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
extensions = g_stSettings.m_videoExtensions;
}
else if (media.Equals("music"))
{
regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
extensions = g_stSettings.m_musicExtensions;
}
else if (media.Equals("pictures"))
{
regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;
extensions = g_stSettings.m_pictureExtensions;
}
if (directory.GetDirectory(strPath, items, extensions))
{
CFileItemList filteredDirectories;
for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
{
if (CUtil::ExcludeFileOrFolder(items[i]->m_strPath, regexps))
continue;
if (items[i]->m_bIsFolder)
filteredDirectories.Add(items[i]);
else
list.Add(items[i]);
}
if (parameterObject.isMember("recursive") && parameterObject["recursive"].isBool())
{
for (int i = 0; i < filteredDirectories.Size(); i++)
{
Value val = parameterObject;
val["directory"] = filteredDirectories[i]->m_strPath;
FillFileItemList(val, list);
}
}
return true;
}
}
}
return false;
}
示例5: GetDirectory
JSON_STATUS CFileOperations::GetDirectory(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CStdString media = parameterObject["media"].asString();
media = media.ToLower();
CDirectory directory;
CFileItemList items;
CStdString strPath = parameterObject["directory"].asString();
CStdStringArray regexps;
CStdString extensions = "";
if (media.Equals("video"))
{
regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
extensions = g_settings.m_videoExtensions;
}
else if (media.Equals("music"))
{
regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
extensions = g_settings.m_musicExtensions;
}
else if (media.Equals("pictures"))
{
regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;
extensions = g_settings.m_pictureExtensions;
}
if (directory.GetDirectory(strPath, items, extensions))
{
CFileItemList filteredDirectories, filteredFiles;
for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
{
if (CUtil::ExcludeFileOrFolder(items[i]->GetPath(), regexps))
continue;
if (items[i]->IsSmb())
{
CURL url(items[i]->GetPath());
items[i]->SetPath(url.GetWithoutUserDetails());
}
if (items[i]->m_bIsFolder)
filteredDirectories.Add(items[i]);
else if ((media == "video" && items[i]->HasVideoInfoTag()) ||
(media == "music" && items[i]->HasMusicInfoTag()))
filteredFiles.Add(items[i]);
else
{
CFileItem fileItem;
if (FillFileItem(items[i]->GetPath(), fileItem, media))
filteredFiles.Add(CFileItemPtr(new CFileItem(fileItem)));
}
}
// Check if the "fields" list exists
// and make sure it contains the "file"
// field
CVariant param = parameterObject;
if (!param.isMember("fields"))
param["fields"] = CVariant(CVariant::VariantTypeArray);
bool hasFileField = false;
for (CVariant::const_iterator_array itr = param["fields"].begin_array(); itr != param["fields"].end_array(); itr++)
{
if (*itr == CVariant("file"))
{
hasFileField = true;
break;
}
}
if (!hasFileField)
param["fields"].append("file");
HandleFileItemList(NULL, true, "files", filteredDirectories, param, result);
for (unsigned int index = 0; index < result["files"].size(); index++)
{
result["files"][index]["filetype"] = "directory";
}
int count = (int)result["limits"]["total"].asInteger();
HandleFileItemList("id", true, "files", filteredFiles, param, result);
for (unsigned int index = count; index < result["files"].size(); index++)
{
result["files"][index]["filetype"] = "file";
}
count += (int)result["limits"]["total"].asInteger();
result["limits"]["end"] = count;
result["limits"]["total"] = count;
return OK;
}
return InvalidParams;
}